Skip to content

Commit bd63d5f

Browse files
authored
Merge pull request #51 from Sharmaz/chore/internal-improvements
Chore/internal improvements
2 parents 6d36d07 + ea9c64d commit bd63d5f

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

41 files changed

+551
-697
lines changed

.github/workflows/e2e_tests.yml

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,13 +8,14 @@ jobs:
88
runs-on: ubuntu-latest
99
strategy:
1010
matrix:
11-
node: [20]
11+
node: [24]
1212
steps:
1313
- uses: actions/checkout@v4
14-
- name: Setup Node 20
14+
- name: Setup Node ${{ matrix.node }}
1515
uses: actions/setup-node@v4
1616
with:
17-
node-version: 20
18-
- run: npm install
17+
node-version: ${{ matrix.node }}
18+
cache: 'npm'
19+
- run: npm ci
1920
- run: npm run build
2021
- run: npm run test:e2e

.github/workflows/linter.yml

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,12 +8,13 @@ jobs:
88
runs-on: ubuntu-latest
99
strategy:
1010
matrix:
11-
node: [20]
11+
node: [24]
1212
steps:
1313
- uses: actions/checkout@v4
14-
- name: Setup Node 20
14+
- name: Setup Node ${{ matrix.node }}
1515
uses: actions/setup-node@v4
1616
with:
17-
node-version: 20
18-
- run: npm install
17+
node-version: ${{ matrix.node }}
18+
cache: 'npm'
19+
- run: npm ci
1920
- run: npm run lint

.github/workflows/publish.yml

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -6,18 +6,17 @@ on:
66
jobs:
77
build:
88
runs-on: ubuntu-latest
9-
strategy:
10-
matrix:
11-
node: [20]
9+
permissions:
10+
contents: read
11+
id-token: write
1212
steps:
1313
- uses: actions/checkout@v4
14-
- name: Setup Node 20
14+
- name: Setup Node
1515
uses: actions/setup-node@v4
1616
with:
17-
node-version: 20
17+
node-version: 22
1818
registry-url: 'https://registry.npmjs.org'
19+
- run: npm install -g npm@latest
1920
- run: npm ci
2021
- run: npm run build
21-
- run: npm publish
22-
env:
23-
NODE_AUTH_TOKEN: ${{secrets.NPM_TOKEN}}
22+
- run: npm publish --provenance

.github/workflows/unit_tests.yml

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,13 +8,14 @@ jobs:
88
runs-on: ubuntu-latest
99
strategy:
1010
matrix:
11-
node: [20]
11+
node: [24]
1212
steps:
1313
- uses: actions/checkout@v4
14-
- name: Setup Node 20
14+
- name: Setup Node ${{ matrix.node }}
1515
uses: actions/setup-node@v4
1616
with:
17-
node-version: 20
18-
- run: npm install
17+
node-version: ${{ matrix.node }}
18+
cache: 'npm'
19+
- run: npm ci
1920
- run: npm run build
2021
- run: npm run test:unit

.gitignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -89,3 +89,6 @@ lerna-debug.log
8989
# System Files
9090
.DS_Store
9191
Thumbs.db
92+
93+
# AI generated files
94+
CLAUDE.md

.prettierrc.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"tabWidth": 2,
3-
"useTabs": true,
3+
"useTabs": false,
44
"printWidth": 120,
55
"semi": true,
66
"trailingComma": "es5",

__tests__/__mocks__/dataMock.js

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@ import { join } from 'node:path';
33

44
import templateCategories from '../../src/templateList';
55

6-
76
const dirname = url.fileURLToPath(new URL('.', import.meta.url));
87
const mainPath = join(dirname, '../..');
98
const appNameMock = 'test-app';

__tests__/e2e/react_rspack.e2e.test.js

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@ beforeAll(() => rm(genPath, { recursive: true, force: true }));
88
afterEach(() => rm(genPath, { recursive: true, force: true }));
99

1010
describe('react-rspack template', () => {
11-
1211
test('prompt shows React Rust', async () => {
1312
const { exitCode, stdout } = await runTest([mainPath], [ENTER, DOWN, DOWN, DOWN]);
1413

@@ -18,7 +17,7 @@ describe('react-rspack template', () => {
1817

1918
test('implemented react-rspack template', async () => {
2019
await execa`node index.js --template react-rspack ${appNameMock}`;
21-
20+
2221
const packageJson = readFileSync(`${genPath}/package.json`, 'utf8');
2322
expect(packageJson).toContain('rspack');
2423
});

__tests__/unit/appName.unit.test.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ describe('App name fuctions', () => {
1111
const formattedNameFromSpaces = formatAppName(wrongFormatSpaces);
1212
const formattedNameFromLowDashes = formatAppName(wrongFormatLowDash);
1313
const formattedNameFromUpperCases = formatAppName(wrongFormatUpperCase);
14-
14+
1515
expect(formattedNameFromSpaces).toBe(appNameMock);
1616
expect(formattedNameFromLowDashes).toBe(appNameMock);
1717
expect(formattedNameFromUpperCases).toBe(appNameMock);

__tests__/unit/colors.unit.test.js

Lines changed: 80 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,80 @@
1+
import { describe, test, expect } from '@jest/globals';
2+
import { separator, setColor, setUnderlineOff } from '../../src/utils/colors';
3+
4+
describe('separator', () => {
5+
test('returns a string with correct padding', () => {
6+
const result = separator('React');
7+
expect(typeof result).toBe('string');
8+
expect(result).toContain('|');
9+
});
10+
11+
test('shorter titles produce more padding', () => {
12+
const short = separator('React');
13+
const long = separator('React Dev Webpack');
14+
expect(short.length).toBeGreaterThan(long.length);
15+
});
16+
});
17+
18+
describe('setColor', () => {
19+
test('returns colored string for Frontend', () => {
20+
const result = setColor('Frontend');
21+
expect(result).toContain('Frontend');
22+
});
23+
24+
test('returns colored string for Backend', () => {
25+
const result = setColor('Backend');
26+
expect(result).toContain('Backend');
27+
});
28+
29+
test('returns colored string for VanillaJS', () => {
30+
const result = setColor('VanillaJS');
31+
expect(result).toContain('VanillaJS');
32+
});
33+
34+
test('returns colored string for NodeJS', () => {
35+
const result = setColor('NodeJS');
36+
expect(result).toContain('NodeJS');
37+
});
38+
39+
test('returns colored string for values containing Node', () => {
40+
const result = setColor('Node Express');
41+
expect(result).toContain('Node Express');
42+
});
43+
44+
test('returns colored string for values containing JavaScript', () => {
45+
const result = setColor('React JavaScript');
46+
expect(result).toContain('React JavaScript');
47+
});
48+
49+
test('returns colored string for values containing Rspack', () => {
50+
const result = setColor('React Rspack');
51+
expect(result).toContain('React Rspack');
52+
});
53+
54+
test('returns colored string for values containing Rust', () => {
55+
const result = setColor('React Rust');
56+
expect(result).toContain('React Rust');
57+
});
58+
59+
test('returns colored string for values containing TypeScript', () => {
60+
const result = setColor('React TypeScript');
61+
expect(result).toContain('React TypeScript');
62+
});
63+
64+
test('returns colored string for values containing React', () => {
65+
const result = setColor('React');
66+
expect(result).toContain('React');
67+
});
68+
69+
test('returns uncolored string for unknown values', () => {
70+
const result = setColor('Unknown');
71+
expect(result).toBe('Unknown');
72+
});
73+
});
74+
75+
describe('setUnderlineOff', () => {
76+
test('returns a reset string', () => {
77+
const result = setUnderlineOff('some text');
78+
expect(result).toContain('some text');
79+
});
80+
});

0 commit comments

Comments
 (0)