Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { defineConfig, type PartialEggConfig } from 'egg';
import { defineConfigFactory, type PartialEggConfig } from 'egg';

export default defineConfig(appInfo => {
export default defineConfigFactory(appInfo => {
const config = {
// use for cookie sign key, should change to your own and keep security
keys: appInfo.name + '_{{keys}}',
Expand Down
1 change: 1 addition & 0 deletions tools/create-egg/src/templates/simple-ts/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
"ci": "vitest run --coverage",
"postci": "npm run prepublishOnly && npm start && sleep 10 && npm stop && npm run clean",
"lint": "oxlint --type-aware",
"typecheck": "tsc --noEmit",
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

It's great that you've added a typecheck script. To ensure type safety is checked automatically during the continuous integration process, consider adding this script to the preci hook. This would make the CI pipeline more robust.

For example:

"preci": "npm run clean && npm run lint && npm run typecheck"

"tsc": "tsc",
"clean": "tsc -b --clean",
"prepublishOnly": "npm run clean && npm run tsc"
Expand Down
4 changes: 2 additions & 2 deletions tools/create-egg/src/templates/tegg/config/config.default.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { defineConfig, type PartialEggConfig } from 'egg';
import { defineConfigFactory, type PartialEggConfig } from 'egg';

export default defineConfig(appInfo => {
export default defineConfigFactory(appInfo => {
const config = {
// use for cookie sign key, should change to your own and keep security
keys: appInfo.name + '_{{keys}}',
Expand Down
1 change: 1 addition & 0 deletions tools/create-egg/src/templates/tegg/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
"ci": "npm run test:local -- --coverage",
"postci": "npm run prepublishOnly && npm start && sleep 10 && npm stop && npm run clean",
"lint": "oxlint --type-aware",
"typecheck": "tsc --noEmit",
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

Adding the typecheck script is a good improvement. To make it even more effective, you could integrate it into your CI workflow by adding it to the preci script. This will help catch type errors early in the development process.

For example:

"preci": "npm run clean && npm run lint && npm run typecheck"

"tsc": "tsc",
"clean": "tsc -b --clean",
"prepublishOnly": "npm run clean && npm run tsc"
Expand Down
4 changes: 4 additions & 0 deletions tools/create-egg/test/cli.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -129,6 +129,8 @@ test.skipIf(process.platform === 'win32')(
execaCommandSync(`pnpm link ${mockDir} ${eggDir} ${binDir} ${tracerDir}`, { cwd: projectDir });
const { stdout: testStdout } = execaCommandSync('pnpm test:local', { cwd: projectDir });
expect(testStdout).toContain('2 passed');
// run typecheck
execaCommandSync('pnpm typecheck', { cwd: projectDir });
}
);

Expand All @@ -155,6 +157,8 @@ test.skipIf(process.platform === 'win32')('successfully scaffolds a project base
execaCommandSync(`pnpm link ${mockDir} ${eggDir} ${binDir} ${tracerDir}`, { cwd: projectDir });
const { stdout: testStdout } = execaCommandSync('pnpm test:local', { cwd: projectDir });
expect(testStdout).toContain('2 passed');
// run typecheck
execaCommandSync('pnpm typecheck', { cwd: projectDir });
});

test('works with the -t alias', () => {
Expand Down
Loading