@qlover/create-app 0.1.4 → 0.1.6
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +9 -0
- package/bin/create-app.js +44 -4
- package/{templates/pack-app → configs/_common}/.env.template +8 -1
- package/{templates/pack-app → configs/_common}/.github/workflows/general-check.yml +9 -9
- package/{templates/pack-app → configs/_common}/.github/workflows/release.yml.template +26 -26
- package/configs/_common/.prettierrc.js +7 -0
- package/configs/_common/.release-it.json.template +42 -0
- package/configs/_common/.vscode/extensions.json +9 -0
- package/configs/_common/.vscode/react.code-snippets +19 -0
- package/configs/_common/.vscode/settings.json +11 -0
- package/configs/_common/package.json.template +61 -0
- package/configs/node-lib/eslint.config.js +50 -0
- package/configs/react-app/eslint.config.js +66 -0
- package/dist/cjs/index.d.ts +58 -38
- package/dist/cjs/index.js +1 -1
- package/dist/es/index.d.ts +58 -38
- package/dist/es/index.js +1 -1
- package/package.json +3 -1
- package/templates/node-lib/__tests__/readJson.test.ts +1 -0
- package/templates/node-lib/bin/test.js +30 -0
- package/templates/node-lib/package.json +22 -6
- package/templates/node-lib/rollup.config.js +12 -22
- package/templates/node-lib/src/readJson.ts +9 -3
- package/templates/node-lib/tsconfig.json +19 -1
- package/templates/pack-app/eslint.config.js +81 -61
- package/templates/pack-app/fe-config.json +1 -5
- package/templates/pack-app/package.json +19 -11
- package/templates/pack-app/tsconfig.json +1 -1
- package/templates/pack-app/vite.config.ts +14 -0
- package/templates/react-app/README.md +177 -40
- package/templates/react-app/config/i18n.ts +1 -1
- package/templates/react-app/lib/fe-react-controller/FeController.ts +7 -3
- package/templates/react-app/lib/fe-react-theme/ThemeController.ts +1 -1
- package/templates/react-app/package.json +53 -9
- package/templates/react-app/src/App.tsx +4 -5
- package/templates/react-app/src/{services → base/apis}/feApi/FeApiMockPlugin.ts +1 -1
- package/templates/react-app/src/base/cases/UserToken.ts +47 -0
- package/templates/react-app/src/base/port/IOCInterface.ts +53 -0
- package/templates/react-app/src/base/port/StorageTokenInterface.ts +5 -0
- package/templates/react-app/src/{types → base/port}/UIDependenciesInterface.ts +6 -0
- package/templates/react-app/src/{types → base/types}/global.d.ts +1 -1
- package/templates/react-app/src/components/ThemeSwitcher.tsx +3 -2
- package/templates/react-app/src/core/bootstrap.ts +21 -0
- package/templates/react-app/src/core/feIOC/FeIOC.ts +32 -0
- package/templates/react-app/src/core/feIOC/RegisterApi.ts +41 -0
- package/templates/react-app/src/core/feIOC/RegisterCommon.ts +20 -0
- package/templates/react-app/src/core/feIOC/RegisterControllers.ts +53 -0
- package/templates/react-app/src/core/index.ts +31 -0
- package/templates/react-app/src/main.tsx +8 -10
- package/templates/react-app/src/pages/404.tsx +2 -2
- package/templates/react-app/src/pages/500.tsx +1 -1
- package/templates/react-app/src/pages/auth/Layout.tsx +3 -2
- package/templates/react-app/src/pages/auth/Login.tsx +6 -4
- package/templates/react-app/src/pages/base/About.tsx +1 -1
- package/templates/react-app/src/pages/base/Executor.tsx +8 -4
- package/templates/react-app/src/pages/base/Home.tsx +1 -1
- package/templates/react-app/src/pages/base/JSONStorage.tsx +6 -4
- package/templates/react-app/src/pages/base/Layout.tsx +1 -1
- package/templates/react-app/src/pages/base/RedirectPathname.tsx +1 -1
- package/templates/react-app/src/pages/base/Request.tsx +8 -3
- package/templates/react-app/src/pages/index.tsx +7 -2
- package/templates/react-app/src/services/{pageProcesser/PageProcesser.ts → processer/ProcesserService.ts} +3 -3
- package/templates/react-app/src/{containers/context → uikit/contexts}/BaseRouteContext.ts +4 -4
- package/templates/react-app/src/{services → uikit}/controllers/ExecutorController.ts +5 -5
- package/templates/react-app/src/{services → uikit}/controllers/JSONStorageController.ts +2 -2
- package/templates/react-app/src/{services → uikit}/controllers/RequestController.ts +3 -3
- package/templates/react-app/src/{services → uikit}/controllers/RouterController.ts +2 -2
- package/templates/react-app/src/{services → uikit}/controllers/UserController.ts +25 -51
- package/templates/react-app/src/{containers/context → uikit/providers}/BaseRouteProvider.tsx +2 -2
- package/templates/react-app/src/{components → uikit/providers}/ProcessProvider.tsx +13 -7
- package/templates/react-app/tsconfig.json +27 -5
- package/templates/react-app/tsconfig.node.json +3 -15
- package/templates/react-app/vite.config.ts +15 -12
- package/templates/pack-app/.env +0 -5
- package/templates/pack-app/.gitignore.template +0 -50
- package/templates/pack-app/.prettierrc.js +0 -3
- package/templates/pack-app/CHANGELOG.md +0 -0
- package/templates/pack-app/jest.config.js +0 -31
- package/templates/react-app/eslint.config.js +0 -31
- package/templates/react-app/src/containers/index.ts +0 -71
- package/templates/react-app/src/services/pageProcesser/index.ts +0 -1
- package/templates/react-app/tsconfig.app.json +0 -29
- package/templates/react-vite-lib/.gitignore.template +0 -27
- package/templates/react-vite-lib/README.md +0 -50
- package/templates/react-vite-lib/__tests__/Sum.test.ts +0 -9
- package/templates/react-vite-lib/__tests__/Text.test.tsx +0 -11
- package/templates/react-vite-lib/eslint.config.js +0 -28
- package/templates/react-vite-lib/index.html +0 -13
- package/templates/react-vite-lib/package.json +0 -30
- package/templates/react-vite-lib/public/vite.svg +0 -1
- package/templates/react-vite-lib/src/calc.ts +0 -3
- package/templates/react-vite-lib/src/commponents/Text.tsx +0 -7
- package/templates/react-vite-lib/src/index.ts +0 -2
- package/templates/react-vite-lib/src/vite-env.d.ts +0 -1
- package/templates/react-vite-lib/tsconfig.json +0 -25
- package/templates/react-vite-lib/vite.config.ts +0 -24
- /package/{templates/pack-app → configs/_common}/.editorconfig +0 -0
- /package/{templates/pack-app → configs/_common}/.gitattributes +0 -0
- /package/{templates/react-app → configs/_common}/.gitignore.template +0 -0
- /package/{templates/pack-app → configs/_common}/.prettierignore +0 -0
- /package/templates/react-app/src/{services → base/apis}/feApi/FeApi.ts +0 -0
- /package/templates/react-app/src/{services → base/apis}/feApi/FeApiType.ts +0 -0
- /package/templates/react-app/src/{services → base/apis}/feApi/index.ts +0 -0
- /package/templates/react-app/src/{types → base/types}/Page.ts +0 -0
- /package/templates/react-app/src/{containers → core}/globals.ts +0 -0
- /package/templates/react-app/src/{hooks → uikit/hooks}/useLanguageGuard.ts +0 -0
- /package/templates/react-app/src/{hooks → uikit/hooks}/useStrictEffect.ts +0 -0
- /package/templates/react-app/src/{styles → uikit/styles}/css/index.css +0 -0
- /package/templates/react-app/src/{styles → uikit/styles}/css/page.css +0 -0
- /package/templates/react-app/src/{styles → uikit/styles}/css/tailwind.css +0 -0
- /package/templates/react-app/src/{utils → uikit/utils}/RequestLogger.ts +0 -0
- /package/templates/react-app/src/{utils → uikit/utils}/datetime.ts +0 -0
- /package/templates/react-app/src/{utils → uikit/utils}/thread.ts +0 -0
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,14 @@
|
|
|
1
1
|
|
|
2
2
|
|
|
3
|
+
## [0.1.6](https://github.com/qlover/fe-base/compare/create-app-v0.1.5...create-app-v0.1.6) (2025-02-14)
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
### Features
|
|
7
|
+
|
|
8
|
+
* template context ([#241](https://github.com/qlover/fe-base/issues/241)) ([9fb3046](https://github.com/qlover/fe-base/commit/9fb3046e3e67c02e5fe4fea81a9a3ef8422e3013))
|
|
9
|
+
|
|
10
|
+
## [0.1.5](https://github.com/qlover/fe-base/compare/create-app-v0.1.4...create-app-v0.1.5) (2025-02-13)
|
|
11
|
+
|
|
3
12
|
## [0.1.4](https://github.com/qlover/fe-base/compare/create-app-v0.1.3...create-app-v0.1.4) (2025-01-20)
|
|
4
13
|
|
|
5
14
|
## [0.1.3](https://github.com/qlover/fe-base/compare/create-app-v0.1.2...create-app-v0.1.3) (2025-01-17)
|
package/bin/create-app.js
CHANGED
|
@@ -3,24 +3,64 @@
|
|
|
3
3
|
import { fileURLToPath } from 'url';
|
|
4
4
|
import { dirname, join } from 'path';
|
|
5
5
|
import { Generator } from '../dist/es/index.js';
|
|
6
|
-
import { existsSync } from 'fs';
|
|
6
|
+
import { existsSync, readFileSync } from 'fs';
|
|
7
|
+
import { Command } from 'commander';
|
|
8
|
+
|
|
9
|
+
const __dirname = dirname(fileURLToPath(import.meta.url));
|
|
10
|
+
const pkg = JSON.parse(
|
|
11
|
+
readFileSync(join(__dirname, '../package.json'), 'utf-8')
|
|
12
|
+
);
|
|
13
|
+
|
|
14
|
+
function programArgs() {
|
|
15
|
+
const program = new Command();
|
|
16
|
+
|
|
17
|
+
program.version(pkg.version, '-v, --version', 'Show version');
|
|
18
|
+
|
|
19
|
+
program
|
|
20
|
+
.option(
|
|
21
|
+
'-d, --dry-run',
|
|
22
|
+
'Do not touch or write anything, but show the commands'
|
|
23
|
+
)
|
|
24
|
+
.option('-V, --verbose', 'Show more information')
|
|
25
|
+
.option('--config', 'Copy config files (default: true)', true)
|
|
26
|
+
.option('--no-config', 'Do not copy config files');
|
|
27
|
+
|
|
28
|
+
// parse arguments
|
|
29
|
+
program.parse();
|
|
30
|
+
|
|
31
|
+
return program.opts();
|
|
32
|
+
}
|
|
7
33
|
|
|
8
34
|
async function main() {
|
|
9
|
-
const
|
|
35
|
+
const { dryRun, verbose, ...commandOptions } = programArgs();
|
|
36
|
+
|
|
10
37
|
const templateRootPath = join(__dirname, '../templates');
|
|
38
|
+
const configsRootPath = join(__dirname, '../configs');
|
|
11
39
|
|
|
12
40
|
if (!existsSync(templateRootPath)) {
|
|
13
41
|
console.error('Template is empty!');
|
|
14
42
|
process.exit(1);
|
|
15
43
|
}
|
|
16
44
|
|
|
45
|
+
if (!existsSync(configsRootPath)) {
|
|
46
|
+
console.error('Configs is empty!');
|
|
47
|
+
process.exit(1);
|
|
48
|
+
}
|
|
49
|
+
|
|
17
50
|
const generator = new Generator({
|
|
51
|
+
dryRun,
|
|
52
|
+
verbose,
|
|
18
53
|
options: {
|
|
19
|
-
|
|
54
|
+
...commandOptions,
|
|
55
|
+
templateRootPath,
|
|
56
|
+
configsRootPath
|
|
20
57
|
}
|
|
21
58
|
});
|
|
22
59
|
|
|
23
60
|
await generator.generate();
|
|
24
61
|
}
|
|
25
62
|
|
|
26
|
-
main()
|
|
63
|
+
main().catch((err) => {
|
|
64
|
+
console.error(err);
|
|
65
|
+
process.exit(1);
|
|
66
|
+
});
|
|
@@ -26,19 +26,19 @@ jobs:
|
|
|
26
26
|
with:
|
|
27
27
|
node-version: '18.19.0'
|
|
28
28
|
|
|
29
|
-
- name: Install
|
|
29
|
+
- name: Install Pnpm
|
|
30
30
|
run: |
|
|
31
|
-
npm install -g
|
|
32
|
-
|
|
31
|
+
npm install -g pnpm
|
|
32
|
+
pnpm -v
|
|
33
33
|
|
|
34
|
-
- name: Lint
|
|
35
|
-
run:
|
|
34
|
+
- name: Pnpm Lint
|
|
35
|
+
run: pnpm lint
|
|
36
36
|
|
|
37
|
-
- name: Test
|
|
38
|
-
run:
|
|
37
|
+
- name: Pnpm Test
|
|
38
|
+
run: pnpm test
|
|
39
39
|
|
|
40
|
-
- name: Build
|
|
41
|
-
run:
|
|
40
|
+
- name: Pnpm Build
|
|
41
|
+
run: pnpm build
|
|
42
42
|
|
|
43
43
|
# check packages
|
|
44
44
|
# - name: Check packages
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
name: Release [
|
|
1
|
+
name: Release [TPL:projectName]
|
|
2
2
|
|
|
3
3
|
on:
|
|
4
4
|
workflow_dispatch:
|
|
@@ -8,14 +8,14 @@ on:
|
|
|
8
8
|
types:
|
|
9
9
|
- closed
|
|
10
10
|
paths:
|
|
11
|
-
- [
|
|
11
|
+
- [TPL:releasePath]/**
|
|
12
12
|
|
|
13
13
|
jobs:
|
|
14
14
|
release-PR:
|
|
15
|
-
# only run when PR merged and has changes:[
|
|
15
|
+
# only run when PR merged and has changes:[TPL:projectName] and CI-Release labels
|
|
16
16
|
if: |
|
|
17
17
|
github.event.pull_request.merged == true &&
|
|
18
|
-
contains(github.event.pull_request.labels.*.name, 'changes:[
|
|
18
|
+
contains(github.event.pull_request.labels.*.name, 'changes:[TPL:projectName]') &&
|
|
19
19
|
!contains(github.event.pull_request.labels.*.name, 'CI-Release')
|
|
20
20
|
runs-on: ubuntu-latest
|
|
21
21
|
|
|
@@ -35,32 +35,32 @@ jobs:
|
|
|
35
35
|
with:
|
|
36
36
|
node-version: '18.19.0'
|
|
37
37
|
|
|
38
|
-
- name: Install
|
|
38
|
+
- name: Install Pnpm
|
|
39
39
|
run: |
|
|
40
|
-
npm install -g
|
|
41
|
-
|
|
40
|
+
npm install -g pnpm
|
|
41
|
+
pnpm -v
|
|
42
42
|
|
|
43
|
-
- name: Lint
|
|
44
|
-
run:
|
|
43
|
+
- name: Pnpm Lint
|
|
44
|
+
run: pnpm lint
|
|
45
45
|
|
|
46
|
-
- name: Test
|
|
47
|
-
run:
|
|
46
|
+
- name: Pnpm Test
|
|
47
|
+
run: pnpm test
|
|
48
48
|
|
|
49
|
-
- name: Build
|
|
50
|
-
run:
|
|
49
|
+
- name: Pnpm Build
|
|
50
|
+
run: pnpm build
|
|
51
51
|
|
|
52
52
|
- name: Create release PR
|
|
53
|
-
run: npm run release-pr:[
|
|
53
|
+
run: npm run release-pr:[TPL:projectName]
|
|
54
54
|
env:
|
|
55
55
|
GITHUB_TOKEN: ${{ secrets.PAT_TOKEN}}
|
|
56
56
|
NPM_TOKEN: ${{ secrets.NPM_TOKEN}}
|
|
57
57
|
PAT_TOKEN: ${{ secrets.PAT_TOKEN }}
|
|
58
58
|
|
|
59
59
|
release:
|
|
60
|
-
# only run when PR merged and has changes:[
|
|
60
|
+
# only run when PR merged and has changes:[TPL:projectName] and CI-Release labels
|
|
61
61
|
if: |
|
|
62
62
|
github.event.pull_request.merged == true &&
|
|
63
|
-
contains(github.event.pull_request.labels.*.name, 'changes:[
|
|
63
|
+
contains(github.event.pull_request.labels.*.name, 'changes:[TPL:projectName]') &&
|
|
64
64
|
contains(github.event.pull_request.labels.*.name, 'CI-Release')
|
|
65
65
|
|
|
66
66
|
runs-on: ubuntu-latest
|
|
@@ -82,22 +82,22 @@ jobs:
|
|
|
82
82
|
with:
|
|
83
83
|
node-version: '18.19.0'
|
|
84
84
|
|
|
85
|
-
- name: Install
|
|
85
|
+
- name: Install Pnpm
|
|
86
86
|
run: |
|
|
87
|
-
npm install -g
|
|
88
|
-
|
|
87
|
+
npm install -g pnpm
|
|
88
|
+
pnpm -v
|
|
89
89
|
|
|
90
|
-
- name: Lint
|
|
91
|
-
run:
|
|
90
|
+
- name: Pnpm Lint
|
|
91
|
+
run: pnpm lint
|
|
92
92
|
|
|
93
|
-
- name: Test
|
|
94
|
-
run:
|
|
93
|
+
- name: Pnpm Test
|
|
94
|
+
run: pnpm test
|
|
95
95
|
|
|
96
|
-
- name: Build
|
|
97
|
-
run:
|
|
96
|
+
- name: Pnpm Build
|
|
97
|
+
run: pnpm build
|
|
98
98
|
|
|
99
99
|
- name: Create tag and publish
|
|
100
|
-
run: npm run release:[
|
|
100
|
+
run: npm run release:[TPL:projectName]
|
|
101
101
|
env:
|
|
102
102
|
GITHUB_TOKEN: ${{ secrets.PAT_TOKEN}}
|
|
103
103
|
NPM_TOKEN: ${{ secrets.NPM_TOKEN}}
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
{
|
|
2
|
+
"git": {
|
|
3
|
+
"commitMessage": "chore(tag): [TPL:projectName] v${version}",
|
|
4
|
+
"tagName": "[TPL:projectName]-v${version}",
|
|
5
|
+
"tagMatch": "[TPL:projectName]-v*",
|
|
6
|
+
"tagAnnotation": "chore(tag): [TPL:projectName] v${version}",
|
|
7
|
+
"push": true,
|
|
8
|
+
"pushArgs": ["--follow-tags"]
|
|
9
|
+
},
|
|
10
|
+
"npm": {
|
|
11
|
+
"publishPath": "",
|
|
12
|
+
"versionArgs": ["--allow-same-version", "--workspaces-update=false"]
|
|
13
|
+
},
|
|
14
|
+
"github": {
|
|
15
|
+
"release": true,
|
|
16
|
+
"releaseName": "chore(tag): [TPL:projectName] v${version}"
|
|
17
|
+
},
|
|
18
|
+
|
|
19
|
+
"plugins": {
|
|
20
|
+
"@release-it/conventional-changelog": {
|
|
21
|
+
"infile": "CHANGELOG.md",
|
|
22
|
+
"preset": {
|
|
23
|
+
"name": "conventionalcommits",
|
|
24
|
+
"types": [
|
|
25
|
+
{ "type": "feat", "section": "Features" },
|
|
26
|
+
{ "type": "fix", "section": "Bug Fixes" },
|
|
27
|
+
{ "type": "revert", "section": "Reverts" },
|
|
28
|
+
{ "type": "build", "hidden": true, "section": "Build System" },
|
|
29
|
+
{ "type": "chore", "hidden": true },
|
|
30
|
+
{ "type": "docs", "section": "Documentation" },
|
|
31
|
+
{ "type": "style", "hidden": true },
|
|
32
|
+
{ "type": "refactor", "hidden": true },
|
|
33
|
+
{ "type": "perf", "hidden": true },
|
|
34
|
+
{ "type": "test", "hidden": true }
|
|
35
|
+
]
|
|
36
|
+
},
|
|
37
|
+
"gitRawCommitsOpts": {
|
|
38
|
+
"path": "."
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
{
|
|
2
|
+
"react-component": {
|
|
3
|
+
"prefix": "react-component",
|
|
4
|
+
"scope": "typescriptreact",
|
|
5
|
+
"body": [
|
|
6
|
+
"import clsx from 'clsx';",
|
|
7
|
+
"",
|
|
8
|
+
"export type $1Props = {",
|
|
9
|
+
" $2",
|
|
10
|
+
" className?: string;",
|
|
11
|
+
"}",
|
|
12
|
+
"",
|
|
13
|
+
"export function $1({ $2, className }: $1Props) {",
|
|
14
|
+
" return <div data-testid=\"$1\" className={clsx('$3', className)}>$3</div>;",
|
|
15
|
+
"}"
|
|
16
|
+
],
|
|
17
|
+
"description": "创建一个 React 组件"
|
|
18
|
+
}
|
|
19
|
+
}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
{
|
|
2
|
+
"eslint.enable": true,
|
|
3
|
+
"eslint.format.enable": false,
|
|
4
|
+
"files.eol": "\n",
|
|
5
|
+
"editor.tabSize": 2,
|
|
6
|
+
"jest.runMode": "on-demand",
|
|
7
|
+
"tailwindCSS.rootFontSize": 10,
|
|
8
|
+
"editor.snippetSuggestions": "top",
|
|
9
|
+
"vitest.autoRun": false,
|
|
10
|
+
"workbench.view.alwaysShowHeaderActions": true
|
|
11
|
+
}
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "[TPL:projectName]",
|
|
3
|
+
"description": "[TPL:projectName] description",
|
|
4
|
+
"version": "0.0.0",
|
|
5
|
+
"type": "module",
|
|
6
|
+
"private": true,
|
|
7
|
+
"homepage": "",
|
|
8
|
+
"author": "",
|
|
9
|
+
"license": "ISC",
|
|
10
|
+
"main": "./dist/es/index.js",
|
|
11
|
+
"module": "./dist/es/index.js",
|
|
12
|
+
"types": "./dist/es/index.d.ts",
|
|
13
|
+
"exports": {
|
|
14
|
+
".": {
|
|
15
|
+
"types": "./dist/es/index.d.ts",
|
|
16
|
+
"import": "./dist/es/index.js",
|
|
17
|
+
"require": "./dist/cjs/index.js"
|
|
18
|
+
},
|
|
19
|
+
"./cjs/*": "./dist/cjs/*",
|
|
20
|
+
"./es/*": "./dist/es/*",
|
|
21
|
+
"./package.json": "./package.json"
|
|
22
|
+
},
|
|
23
|
+
"repository": {
|
|
24
|
+
"type": "git",
|
|
25
|
+
"url": "",
|
|
26
|
+
"directory": ""
|
|
27
|
+
},
|
|
28
|
+
"files": [
|
|
29
|
+
"bin",
|
|
30
|
+
"dist",
|
|
31
|
+
"package.json",
|
|
32
|
+
"README.md"
|
|
33
|
+
],
|
|
34
|
+
"keywords": [
|
|
35
|
+
"[TPL:projectName]"
|
|
36
|
+
],
|
|
37
|
+
"publishConfig": {
|
|
38
|
+
"access": "public"
|
|
39
|
+
},
|
|
40
|
+
"bin": {},
|
|
41
|
+
"scripts": {
|
|
42
|
+
"build": "pnpm build",
|
|
43
|
+
"test": "vitest run",
|
|
44
|
+
"prettier": "prettier --ignore-path .prettierignore **/*.{js,ts,json,cjs,mjs} --write",
|
|
45
|
+
"lint": "eslint . --fix",
|
|
46
|
+
"clean": "fe-clean",
|
|
47
|
+
"check-packages": "fe-check-packages",
|
|
48
|
+
"commit": "fe-commit",
|
|
49
|
+
"clean-branch": "fe-clean-branch",
|
|
50
|
+
"release:[TPL:projectName]": "release-it"
|
|
51
|
+
},
|
|
52
|
+
"devDependencies": {
|
|
53
|
+
"@qlover/env-loader": "latest",
|
|
54
|
+
"@qlover/fe-standard": "latest",
|
|
55
|
+
"@qlover/fe-scripts": "latest",
|
|
56
|
+
"@qlover/scripts-context": "latest"
|
|
57
|
+
},
|
|
58
|
+
"dependencies": {
|
|
59
|
+
"@qlover/fe-utils": "latest"
|
|
60
|
+
}
|
|
61
|
+
}
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
import js from '@eslint/js';
|
|
2
|
+
import globals from 'globals';
|
|
3
|
+
import prettierConfig from '../../packages/node-lib/.prettierrc.js';
|
|
4
|
+
import prettier from 'eslint-plugin-prettier';
|
|
5
|
+
import tseslint from '@typescript-eslint/eslint-plugin';
|
|
6
|
+
import tsparser from '@typescript-eslint/parser';
|
|
7
|
+
import * as feDev from '@qlover/eslint-plugin-fe-dev';
|
|
8
|
+
|
|
9
|
+
export default [
|
|
10
|
+
{
|
|
11
|
+
ignores: ['dist', 'node_modules']
|
|
12
|
+
},
|
|
13
|
+
{
|
|
14
|
+
files: ['src/**/*.{js,jsx,ts,tsx}'],
|
|
15
|
+
languageOptions: {
|
|
16
|
+
parser: tsparser,
|
|
17
|
+
ecmaVersion: 2020,
|
|
18
|
+
globals: {
|
|
19
|
+
...globals.browser,
|
|
20
|
+
...globals.node
|
|
21
|
+
},
|
|
22
|
+
parserOptions: {
|
|
23
|
+
ecmaVersion: 'latest',
|
|
24
|
+
ecmaFeatures: { jsx: true },
|
|
25
|
+
sourceType: 'module',
|
|
26
|
+
project: './tsconfig.json'
|
|
27
|
+
}
|
|
28
|
+
},
|
|
29
|
+
plugins: {
|
|
30
|
+
prettier,
|
|
31
|
+
'@typescript-eslint': tseslint,
|
|
32
|
+
'fe-dev': feDev
|
|
33
|
+
},
|
|
34
|
+
rules: {
|
|
35
|
+
...js.configs.recommended.rules,
|
|
36
|
+
...tseslint.configs.recommended.rules,
|
|
37
|
+
'@typescript-eslint/no-explicit-any': 'error',
|
|
38
|
+
'prettier/prettier': ['error', prettierConfig],
|
|
39
|
+
'@typescript-eslint/ban-ts-comment': [
|
|
40
|
+
'off',
|
|
41
|
+
{
|
|
42
|
+
'ts-expect-error': {
|
|
43
|
+
descriptionFormat: '^.*$'
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
],
|
|
47
|
+
'fe-dev/ts-class-method-return': 'error'
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
];
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
import js from '@eslint/js';
|
|
2
|
+
import globals from 'globals';
|
|
3
|
+
import react from 'eslint-plugin-react';
|
|
4
|
+
import reactHooks from 'eslint-plugin-react-hooks';
|
|
5
|
+
import reactRefresh from 'eslint-plugin-react-refresh';
|
|
6
|
+
import tseslint from 'typescript-eslint';
|
|
7
|
+
import tsparser from '@typescript-eslint/parser';
|
|
8
|
+
import * as feDev from '@qlover/eslint-plugin-fe-dev';
|
|
9
|
+
import prettier from 'eslint-plugin-prettier';
|
|
10
|
+
import prettierConfig from './.prettierrc.js';
|
|
11
|
+
|
|
12
|
+
export default tseslint.config(
|
|
13
|
+
{ ignores: ['dist', 'node_modules'] },
|
|
14
|
+
{
|
|
15
|
+
extends: [js.configs.recommended, ...tseslint.configs.recommended],
|
|
16
|
+
files: ['src/**/*.{ts,tsx}'],
|
|
17
|
+
languageOptions: {
|
|
18
|
+
parser: tsparser,
|
|
19
|
+
ecmaVersion: 2020,
|
|
20
|
+
globals: {
|
|
21
|
+
...globals.browser,
|
|
22
|
+
...globals.node
|
|
23
|
+
},
|
|
24
|
+
parserOptions: {
|
|
25
|
+
ecmaVersion: 'latest',
|
|
26
|
+
ecmaFeatures: { jsx: true },
|
|
27
|
+
sourceType: 'module',
|
|
28
|
+
project: './tsconfig.json'
|
|
29
|
+
}
|
|
30
|
+
},
|
|
31
|
+
settings: { react: { version: '18.3' } },
|
|
32
|
+
plugins: {
|
|
33
|
+
react,
|
|
34
|
+
'react-hooks': reactHooks,
|
|
35
|
+
'react-refresh': reactRefresh,
|
|
36
|
+
prettier,
|
|
37
|
+
'@typescript-eslint': tseslint,
|
|
38
|
+
'fe-dev': feDev
|
|
39
|
+
},
|
|
40
|
+
rules: {
|
|
41
|
+
...js.configs.recommended.rules,
|
|
42
|
+
...react.configs.recommended.rules,
|
|
43
|
+
...react.configs['jsx-runtime'].rules,
|
|
44
|
+
...reactHooks.configs.recommended.rules,
|
|
45
|
+
...tseslint.configs.recommended.rules,
|
|
46
|
+
'react/jsx-no-target-blank': 'off',
|
|
47
|
+
'react/prefer-stateless-function': 'error',
|
|
48
|
+
'react-refresh/only-export-components': [
|
|
49
|
+
'warn',
|
|
50
|
+
{ allowConstantExport: true }
|
|
51
|
+
],
|
|
52
|
+
'@typescript-eslint/no-explicit-any': 'error',
|
|
53
|
+
'prettier/prettier': ['error', prettierConfig],
|
|
54
|
+
'@typescript-eslint/ban-ts-comment': [
|
|
55
|
+
'off',
|
|
56
|
+
{
|
|
57
|
+
'ts-expect-error': {
|
|
58
|
+
descriptionFormat: '^.*$'
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
],
|
|
62
|
+
'react-hooks/exhaustive-deps': 'off',
|
|
63
|
+
'fe-dev/ts-class-method-return': 'error'
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
);
|
package/dist/cjs/index.d.ts
CHANGED
|
@@ -6,21 +6,54 @@ import ignore from 'ignore';
|
|
|
6
6
|
type GeneratorPrompt = DistinctQuestion;
|
|
7
7
|
type GeneratorOptions = {
|
|
8
8
|
prompts?: GeneratorPrompt[];
|
|
9
|
+
/**
|
|
10
|
+
* template root path
|
|
11
|
+
*/
|
|
9
12
|
templateRootPath: string;
|
|
13
|
+
/**
|
|
14
|
+
* configs root path
|
|
15
|
+
*/
|
|
16
|
+
configsRootPath: string;
|
|
17
|
+
/**
|
|
18
|
+
* whether to copy config files
|
|
19
|
+
*/
|
|
20
|
+
config?: boolean;
|
|
10
21
|
};
|
|
11
|
-
interface
|
|
12
|
-
|
|
22
|
+
interface GeneratorContext extends GeneratorOptions {
|
|
23
|
+
/**
|
|
24
|
+
* project name
|
|
25
|
+
*/
|
|
26
|
+
projectName: string;
|
|
27
|
+
/**
|
|
28
|
+
* choose template name
|
|
29
|
+
*
|
|
30
|
+
* mayby is pack-app
|
|
31
|
+
*/
|
|
13
32
|
template: string;
|
|
33
|
+
/**
|
|
34
|
+
* choose sub packages
|
|
35
|
+
*
|
|
36
|
+
* mayby is ['node-lib', 'react-app']
|
|
37
|
+
*/
|
|
14
38
|
subPackages?: string[];
|
|
15
39
|
/**
|
|
16
40
|
* @default `packages`
|
|
17
41
|
*/
|
|
18
42
|
packagesNames?: string;
|
|
43
|
+
/**
|
|
44
|
+
* Generated project path
|
|
45
|
+
* @default `./`
|
|
46
|
+
*/
|
|
19
47
|
targetPath?: string;
|
|
48
|
+
/**
|
|
49
|
+
* release path
|
|
50
|
+
* @default `src`
|
|
51
|
+
*/
|
|
52
|
+
releasePath?: string;
|
|
20
53
|
}
|
|
21
54
|
type TaskOptions = {
|
|
22
55
|
templateFiles: TemplateFile[];
|
|
23
|
-
result:
|
|
56
|
+
result: GeneratorContext;
|
|
24
57
|
};
|
|
25
58
|
type TemplateFile = {
|
|
26
59
|
path: string;
|
|
@@ -30,42 +63,35 @@ type TemplateFile = {
|
|
|
30
63
|
declare class Generator {
|
|
31
64
|
private ora;
|
|
32
65
|
protected context: FeScriptContext<GeneratorOptions>;
|
|
66
|
+
private subPackages;
|
|
67
|
+
private copyer;
|
|
68
|
+
private compose;
|
|
33
69
|
constructor(context: Partial<FeScriptContext<GeneratorOptions>>);
|
|
34
70
|
get logger(): Logger;
|
|
35
|
-
steps(prompts: GeneratorPrompt[]): Promise<
|
|
71
|
+
steps(prompts: GeneratorPrompt[]): Promise<GeneratorContext>;
|
|
36
72
|
action({ label, task }: {
|
|
37
73
|
label: string;
|
|
38
74
|
task: (() => Promise<unknown>) | (() => unknown);
|
|
39
75
|
}): Promise<unknown>;
|
|
40
|
-
/**
|
|
41
|
-
* Creates files and directories based on the provided template files.
|
|
42
|
-
*
|
|
43
|
-
* This method iterates through the template files and writes their content
|
|
44
|
-
* to the file system. It handles both files and directories, ensuring that
|
|
45
|
-
* the directory structure is preserved.
|
|
46
|
-
*
|
|
47
|
-
* @param result - The result object containing the name and template name.
|
|
48
|
-
*
|
|
49
|
-
* @returns A promise that resolves when all files have been created.
|
|
50
|
-
*
|
|
51
|
-
* @example
|
|
52
|
-
* const result = { name: 'my-app', template: 'react-app' };
|
|
53
|
-
* await this.create(result);
|
|
54
|
-
*/
|
|
55
|
-
create(result: GeneratorResult): Promise<void>;
|
|
56
76
|
private isPackageTemplate;
|
|
57
|
-
|
|
77
|
+
private getGeneratorContext;
|
|
58
78
|
generate(): Promise<void>;
|
|
79
|
+
generateConfigs(context: GeneratorContext, targetPath: string, configName: string): Promise<void>;
|
|
80
|
+
generateTemplateDir(context: GeneratorContext): Promise<void>;
|
|
81
|
+
generateSubPackages(context: GeneratorContext): Promise<void>;
|
|
59
82
|
}
|
|
60
83
|
|
|
61
84
|
declare const validRequiredString: (value: string, key: string) => string | true;
|
|
62
|
-
declare
|
|
63
|
-
declare
|
|
85
|
+
declare function createDefaultPrompts(templates: string[], packages: string[]): GeneratorPrompt[];
|
|
86
|
+
declare function createPackagePrompts(templates: string[]): GeneratorPrompt[];
|
|
64
87
|
|
|
88
|
+
type CopyCallback = (sourceFilePath: string, targetFilePath: string) => boolean | Promise<boolean>;
|
|
65
89
|
declare class Copyer {
|
|
90
|
+
private readonly ignoreTargetPath;
|
|
91
|
+
private readonly ignoreFile;
|
|
66
92
|
static IGNORE_FILE: string;
|
|
67
|
-
|
|
68
|
-
|
|
93
|
+
constructor(ignoreTargetPath: string, ignoreFile?: string);
|
|
94
|
+
getIg(targetDir?: string): ignore.Ignore | undefined;
|
|
69
95
|
/**
|
|
70
96
|
* Asynchronously copy files from source to target directory.
|
|
71
97
|
* @param {string} sourcePath - Source directory.
|
|
@@ -75,18 +101,12 @@ declare class Copyer {
|
|
|
75
101
|
* @example
|
|
76
102
|
* await copyer.copyFilesPromise('src', 'dest', ignoreInstance);
|
|
77
103
|
*/
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
*/
|
|
85
|
-
copyFilesSync(sourePath: string, targetDir: string, ig?: ignore.Ignore): void;
|
|
86
|
-
create(result: GeneratorResult): void;
|
|
87
|
-
createPromise(result: GeneratorResult): Promise<void>;
|
|
88
|
-
createPath(result: GeneratorResult): void;
|
|
89
|
-
createPathPromise(result: GeneratorResult): Promise<void>;
|
|
104
|
+
copyFiles(sourcePath: string, targetDir: string, ig?: ignore.Ignore, copyCallback?: CopyCallback): Promise<void>;
|
|
105
|
+
copyPaths({ sourcePath, targetPath, copyCallback }: {
|
|
106
|
+
sourcePath: string;
|
|
107
|
+
targetPath: string;
|
|
108
|
+
copyCallback?: CopyCallback;
|
|
109
|
+
}): Promise<void>;
|
|
90
110
|
}
|
|
91
111
|
|
|
92
|
-
export { Copyer, Generator, type
|
|
112
|
+
export { type CopyCallback, Copyer, Generator, type GeneratorContext, type GeneratorOptions, type GeneratorPrompt, type TaskOptions, type TemplateFile, createDefaultPrompts, createPackagePrompts, validRequiredString };
|