create-packer 1.19.4 → 1.20.0
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/README.md +4 -4
- package/bin/createTemp.d.ts +1 -0
- package/bin/{clis/createTemp.js → createTemp.js} +18 -12
- package/bin/index.js +2 -6
- package/bin/utils/index.d.ts +7 -1
- package/bin/utils/index.js +31 -6
- package/package.json +2 -2
- package/template/chrome-extension/src/providers/modelUtils.ts +3 -4
- package/template/cli/package.json +1 -1
- package/template/cli/src/{clis/createTemp.ts → createTemp.ts} +18 -17
- package/template/cli/src/index.ts +2 -6
- package/template/cli/src/utils/index.ts +16 -5
- package/template/react/{package.json → react-app/package.json} +1 -1
- package/template/react/{src → react-app/src}/providers/modelUtils.ts +3 -4
- package/template/react/react-lib/.editorconfig +14 -0
- package/template/react/react-lib/.eslintrc +84 -0
- package/template/react/react-lib/.gitignore +26 -0
- package/template/react/react-lib/.prettierignore +4 -0
- package/template/react/react-lib/.prettierrc +18 -0
- package/template/react/react-lib/.storybook/main.ts +17 -0
- package/template/react/react-lib/.storybook/preview.ts +15 -0
- package/template/react/react-lib/.stylelintrc +23 -0
- package/template/react/react-lib/package.json +48 -0
- package/template/react/react-lib/src/Introduction.mdx +3 -0
- package/template/react/react-lib/src/button/button.css +30 -0
- package/template/react/react-lib/src/button/button.stories.ts +43 -0
- package/template/react/react-lib/src/button/button.tsx +50 -0
- package/template/react/react-lib/src/button/index.ts +1 -0
- package/template/react/react-lib/src/index.ts +1 -0
- package/template/react/react-lib/tsconfig.json +24 -0
- package/template/ts-lib/.eslintrc +73 -0
- package/template/ts-lib/.gitignore +25 -0
- package/template/ts-lib/.prettierignore +4 -0
- package/template/ts-lib/.prettierrc +18 -0
- package/template/ts-lib/package.json +23 -0
- package/template/{lib/packages/test → ts-lib}/tsconfig.json +1 -1
- package/template/workspace/pnpm/.prettierrc.js +21 -0
- package/template/workspace/pnpm/README.md +1 -0
- package/template/{lib → workspace/pnpm}/package.json +9 -11
- package/template/workspace/pnpm/packages/test/.eslintrc +73 -0
- package/template/workspace/pnpm/packages/test/.gitignore +25 -0
- package/template/workspace/pnpm/packages/test/.prettierignore +4 -0
- package/template/workspace/pnpm/packages/test/.prettierrc +18 -0
- package/template/workspace/pnpm/packages/test/package.json +23 -0
- package/template/workspace/pnpm/packages/test/src/index.ts +5 -0
- package/template/workspace/pnpm/packages/test/tsconfig.json +17 -0
- package/template/workspace/pnpm/pnpm-lock.yaml +15730 -0
- package/template/workspace/pnpm/scripts/build.ts +8 -0
- package/template/workspace/pnpm/tsconfig.json +17 -0
- package/bin/clis/createTemp.d.ts +0 -5
- package/template/lib/packages/test/.gitignore +0 -35
- package/template/lib/packages/test/package.json +0 -13
- package/template/lib/pnpm-lock.yaml +0 -2900
- /package/template/react/{.editorconfig → react-app/.editorconfig} +0 -0
- /package/template/react/{.env → react-app/.env} +0 -0
- /package/template/react/{.env.development → react-app/.env.development} +0 -0
- /package/template/react/{.eslintrc → react-app/.eslintrc} +0 -0
- /package/template/react/{.gitignore → react-app/.gitignore} +0 -0
- /package/template/{nx → react/react-app}/.husky/commit-msg +0 -0
- /package/template/{nx → react/react-app}/.husky/pre-commit +0 -0
- /package/template/react/{.prettierignore → react-app/.prettierignore} +0 -0
- /package/template/react/{.prettierrc → react-app/.prettierrc} +0 -0
- /package/template/react/{.stylelintrc → react-app/.stylelintrc} +0 -0
- /package/template/react/{.vscode → react-app/.vscode}/extensions.json +0 -0
- /package/template/react/{README.md → react-app/README.md} +0 -0
- /package/template/{lib → react/react-app}/commitlint.config.cjs +0 -0
- /package/template/react/{index.html → react-app/index.html} +0 -0
- /package/template/react/{jest.config.cjs → react-app/jest.config.cjs} +0 -0
- /package/template/react/{jest.setup.ts → react-app/jest.setup.ts} +0 -0
- /package/template/react/{postcss.config.cjs → react-app/postcss.config.cjs} +0 -0
- /package/template/react/{public → react-app/public}/vite.svg +0 -0
- /package/template/react/{src → react-app/src}/app.model.ts +0 -0
- /package/template/react/{src → react-app/src}/assets/react.svg +0 -0
- /package/template/react/{src → react-app/src}/controllers/index.ts +0 -0
- /package/template/react/{src → react-app/src}/controllers/useComponentInstance.ts +0 -0
- /package/template/react/{src → react-app/src}/index.css +0 -0
- /package/template/react/{src → react-app/src}/layout/components/Loading.tsx +0 -0
- /package/template/react/{src → react-app/src}/layout/components/index.ts +0 -0
- /package/template/react/{src → react-app/src}/layout/index.ts +0 -0
- /package/template/react/{src → react-app/src}/layout/layout.container.tsx +0 -0
- /package/template/react/{src → react-app/src}/main.tsx +0 -0
- /package/template/react/{src → react-app/src}/models/index.ts +0 -0
- /package/template/react/{src → react-app/src}/models/useVisible.ts +0 -0
- /package/template/react/{src → react-app/src}/pages/home/home.css +0 -0
- /package/template/react/{src → react-app/src}/pages/home/home.spec.tsx +0 -0
- /package/template/react/{src → react-app/src}/pages/home/home.tsx +0 -0
- /package/template/react/{src → react-app/src}/pages/home/index.ts +0 -0
- /package/template/react/{src → react-app/src}/pages/notFound/index.ts +0 -0
- /package/template/react/{src → react-app/src}/pages/notFound/notFound.tsx +0 -0
- /package/template/react/{src → react-app/src}/providers/componentInstance.tsx +0 -0
- /package/template/react/{src → react-app/src}/providers/index.ts +0 -0
- /package/template/react/{src → react-app/src}/providers/request.ts +0 -0
- /package/template/react/{src → react-app/src}/router/home/ids.ts +0 -0
- /package/template/react/{src → react-app/src}/router/home/index.ts +0 -0
- /package/template/react/{src → react-app/src}/router/home/routes.tsx +0 -0
- /package/template/react/{src → react-app/src}/router/ids.ts +0 -0
- /package/template/react/{src → react-app/src}/router/index.ts +0 -0
- /package/template/react/{src → react-app/src}/router/router.provider.ts +0 -0
- /package/template/react/{src → react-app/src}/router/router.tsx +0 -0
- /package/template/react/{src → react-app/src}/router/router.types.ts +0 -0
- /package/template/react/{src → react-app/src}/types/index.ts +0 -0
- /package/template/react/{src → react-app/src}/types/utils.ts +0 -0
- /package/template/react/{src → react-app/src}/vite-env.d.ts +0 -0
- /package/template/react/{tailwind.config.cjs → react-app/tailwind.config.cjs} +0 -0
- /package/template/react/{tsconfig.json → react-app/tsconfig.json} +0 -0
- /package/template/react/{tsconfig.node.json → react-app/tsconfig.node.json} +0 -0
- /package/template/react/{vite.config.ts → react-app/vite.config.ts} +0 -0
- /package/template/{lib/packages/test → ts-lib}/src/index.ts +0 -0
- /package/template/{nx → workspace/nx}/.editorconfig +0 -0
- /package/template/{nx → workspace/nx}/.eslintignore +0 -0
- /package/template/{nx → workspace/nx}/.eslintrc.json +0 -0
- /package/template/{nx → workspace/nx}/.gitignore +0 -0
- /package/template/{react → workspace/nx}/.husky/commit-msg +0 -0
- /package/template/{react → workspace/nx}/.husky/pre-commit +0 -0
- /package/template/{nx → workspace/nx}/.prettierignore +0 -0
- /package/template/{nx → workspace/nx}/.prettierrc +0 -0
- /package/template/{nx → workspace/nx}/.stylelintrc.json +0 -0
- /package/template/{nx → workspace/nx}/.vscode/extensions.json +0 -0
- /package/template/{nx → workspace/nx}/README.md +0 -0
- /package/template/{nx → workspace/nx}/commitlint.config.cjs +0 -0
- /package/template/{nx → workspace/nx}/jest.config.ts +0 -0
- /package/template/{nx → workspace/nx}/jest.preset.js +0 -0
- /package/template/{nx → workspace/nx}/lerna.json +0 -0
- /package/template/{nx → workspace/nx}/node_modules/.pnpm/minipass-fetch@3.0.3/node_modules/minipass-sized/.gitignore +0 -0
- /package/template/{nx → workspace/nx}/node_modules/.pnpm/minipass-sized@1.0.3/node_modules/minipass-sized/.gitignore +0 -0
- /package/template/{nx → workspace/nx}/node_modules/.pnpm/node_modules/minipass-sized/.gitignore +0 -0
- /package/template/{nx → workspace/nx}/node_modules/.pnpm/node_modules/npm-normalize-package-bin/.gitignore +0 -0
- /package/template/{nx → workspace/nx}/node_modules/.pnpm/npm-bundled@1.1.2/node_modules/npm-normalize-package-bin/.gitignore +0 -0
- /package/template/{nx → workspace/nx}/node_modules/.pnpm/npm-normalize-package-bin@1.0.1/node_modules/npm-normalize-package-bin/.gitignore +0 -0
- /package/template/{nx → workspace/nx}/node_modules/.pnpm/npm-packlist@5.1.1/node_modules/npm-normalize-package-bin/.gitignore +0 -0
- /package/template/{nx → workspace/nx}/nx.json +0 -0
- /package/template/{nx → workspace/nx}/package.json +0 -0
- /package/template/{nx → workspace/nx}/packages/.gitkeep +0 -0
- /package/template/{nx → workspace/nx}/packages/vue-lib/.eslintrc.json +0 -0
- /package/template/{nx → workspace/nx}/packages/vue-lib/README.md +0 -0
- /package/template/{nx → workspace/nx}/packages/vue-lib/jest.config.ts +0 -0
- /package/template/{nx → workspace/nx}/packages/vue-lib/package.json +0 -0
- /package/template/{nx → workspace/nx}/packages/vue-lib/project.json +0 -0
- /package/template/{nx → workspace/nx}/packages/vue-lib/src/index.ts +0 -0
- /package/template/{nx → workspace/nx}/packages/vue-lib/src/lib/HelloWorld.vue +0 -0
- /package/template/{nx → workspace/nx}/packages/vue-lib/src/shims-vue.d.ts +0 -0
- /package/template/{nx → workspace/nx}/packages/vue-lib/tests/unit/example.spec.ts +0 -0
- /package/template/{nx → workspace/nx}/packages/vue-lib/tsconfig.json +0 -0
- /package/template/{nx → workspace/nx}/packages/vue-lib/tsconfig.lib.json +0 -0
- /package/template/{nx → workspace/nx}/packages/vue-lib/tsconfig.spec.json +0 -0
- /package/template/{nx → workspace/nx}/packages/vue-lib/vite.config.ts +0 -0
- /package/template/{lib → workspace/nx}/pnpm-workspace.yaml +0 -0
- /package/template/{nx → workspace/nx}/scripts/patch-nx-dep-graph.js +0 -0
- /package/template/{nx → workspace/nx}/tools/generators/.gitkeep +0 -0
- /package/template/{nx → workspace/nx}/tools/tsconfig.tools.json +0 -0
- /package/template/{nx → workspace/nx}/tsconfig.base.json +0 -0
- /package/template/{lib → workspace/pnpm}/.changeset/README.md +0 -0
- /package/template/{lib → workspace/pnpm}/.changeset/config.json +0 -0
- /package/template/{lib → workspace/pnpm}/.gitignore +0 -0
- /package/template/{react → workspace/pnpm}/commitlint.config.cjs +0 -0
- /package/template/{nx → workspace/pnpm}/pnpm-workspace.yaml +0 -0
package/README.md
CHANGED
|
@@ -5,9 +5,9 @@ Quickly create project templates。
|
|
|
5
5
|
## QuicklyCreate
|
|
6
6
|
|
|
7
7
|
```shell
|
|
8
|
-
npx create-packer
|
|
9
|
-
yarn create packer
|
|
10
|
-
pnpx create-packer
|
|
8
|
+
npx create-packer <. || dirname>
|
|
9
|
+
yarn create packer <. || dirname>
|
|
10
|
+
pnpx create-packer <. || dirname>
|
|
11
11
|
```
|
|
12
12
|
|
|
13
13
|
## TempInfo
|
|
@@ -15,4 +15,4 @@ pnpx create-packer -c <. || dirname>
|
|
|
15
15
|
- docusaurus: Based on [Docusaurus 2](https://v2.docusaurus.io/).
|
|
16
16
|
- nest: Based on [nestjs](https://docs.nestjs.com/).
|
|
17
17
|
- vue: Based on [vite(3.x)](https://cn.vitejs.dev/), [vue3](https://vuejs.org/).
|
|
18
|
-
- react: Based on [vite(3.x)](https://cn.vitejs.dev/), [react18](https://reactjs.org/).
|
|
18
|
+
- react-app: Based on [vite(3.x)](https://cn.vitejs.dev/), [react18](https://reactjs.org/).
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function createTemp(dirname: string): Promise<void>;
|
|
@@ -4,21 +4,16 @@ exports.createTemp = void 0;
|
|
|
4
4
|
const inquirer = require("inquirer");
|
|
5
5
|
const fsExtra = require("fs-extra");
|
|
6
6
|
const path = require("path");
|
|
7
|
-
const fs = require("fs");
|
|
8
7
|
const chalk = require("chalk");
|
|
9
8
|
const ora = require("ora");
|
|
10
9
|
const child_process_1 = require("child_process");
|
|
11
|
-
const utils_1 = require("
|
|
10
|
+
const utils_1 = require("./utils");
|
|
11
|
+
const fs_1 = require("fs");
|
|
12
12
|
const cwd = process.cwd();
|
|
13
13
|
const command = utils_1.onGenCommand();
|
|
14
14
|
const excludes = ['node_modules', 'yarn-error.log', 'dist'];
|
|
15
15
|
const tempRoot = path.join(__dirname, '../../template');
|
|
16
|
-
const
|
|
17
|
-
return {
|
|
18
|
-
name,
|
|
19
|
-
src: path.join(tempRoot, name)
|
|
20
|
-
};
|
|
21
|
-
});
|
|
16
|
+
const tempInfoList = utils_1.genTemplateInfoList(tempRoot);
|
|
22
17
|
function copyTempFile(tempPath, output) {
|
|
23
18
|
fsExtra.readdirSync(tempPath).map(name => {
|
|
24
19
|
if (!excludes.includes(name)) {
|
|
@@ -34,23 +29,34 @@ function createTempEnd(output) {
|
|
|
34
29
|
}
|
|
35
30
|
async function createTemp(dirname) {
|
|
36
31
|
const isCurrent = dirname === '.';
|
|
37
|
-
|
|
32
|
+
let answer = await inquirer.prompt([
|
|
38
33
|
{
|
|
39
34
|
type: 'list',
|
|
40
35
|
name: 'temp',
|
|
41
36
|
message: 'Select temp.',
|
|
42
|
-
choices:
|
|
37
|
+
choices: tempInfoList.map(o => o.name)
|
|
43
38
|
}
|
|
44
39
|
]);
|
|
40
|
+
const tempInfo = tempInfoList.find(o => o.name === answer.temp);
|
|
41
|
+
if (tempInfo.children) {
|
|
42
|
+
answer = await inquirer.prompt([
|
|
43
|
+
{
|
|
44
|
+
type: 'list',
|
|
45
|
+
name: 'temp',
|
|
46
|
+
message: 'Select temp type.',
|
|
47
|
+
choices: tempInfo.children.map(o => o.name)
|
|
48
|
+
}
|
|
49
|
+
]);
|
|
50
|
+
}
|
|
45
51
|
const creating = ora(chalk.yellow('Creating...\n')).start();
|
|
46
52
|
const output = path.join(cwd, isCurrent ? '' : dirname);
|
|
47
|
-
if (!isCurrent &&
|
|
53
|
+
if (!isCurrent && fs_1.existsSync(output)) {
|
|
48
54
|
return console.log(chalk.red(`${dirname} already exists!`));
|
|
49
55
|
}
|
|
50
56
|
if (!isCurrent) {
|
|
51
57
|
fsExtra.mkdirSync(output);
|
|
52
58
|
}
|
|
53
|
-
const tempPath = path.join(tempRoot, temp);
|
|
59
|
+
const tempPath = path.join(tempRoot, answer.temp);
|
|
54
60
|
copyTempFile(tempPath, output);
|
|
55
61
|
createTempEnd(output);
|
|
56
62
|
creating.succeed();
|
package/bin/index.js
CHANGED
|
@@ -1,10 +1,6 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
"use strict";
|
|
3
3
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
4
|
-
const createTemp_1 = require("./
|
|
4
|
+
const createTemp_1 = require("./createTemp");
|
|
5
5
|
const commander_1 = require("commander");
|
|
6
|
-
commander_1.program
|
|
7
|
-
.option('-c, --create <dirname>', 'Create project.', dirname => {
|
|
8
|
-
return createTemp_1.createTemp(dirname);
|
|
9
|
-
})
|
|
10
|
-
.parse(process.argv);
|
|
6
|
+
commander_1.program.argument('<dirname>', 'Create project.', dirname => createTemp_1.createTemp(dirname)).parse(process.argv);
|
package/bin/utils/index.d.ts
CHANGED
|
@@ -1,4 +1,10 @@
|
|
|
1
1
|
export declare function hasPnpm(): boolean;
|
|
2
2
|
export declare function hasYarn(): boolean;
|
|
3
3
|
export declare function onGenCommand(): "pnpm" | "yarn" | "npm";
|
|
4
|
-
|
|
4
|
+
interface tempInfoType {
|
|
5
|
+
name: string;
|
|
6
|
+
src: string;
|
|
7
|
+
children?: tempInfoType[];
|
|
8
|
+
}
|
|
9
|
+
export declare function genTemplateInfoList(root: string): tempInfoType[];
|
|
10
|
+
export {};
|
package/bin/utils/index.js
CHANGED
|
@@ -1,6 +1,26 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
|
|
5
|
+
}) : (function(o, m, k, k2) {
|
|
6
|
+
if (k2 === undefined) k2 = k;
|
|
7
|
+
o[k2] = m[k];
|
|
8
|
+
}));
|
|
9
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
10
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
11
|
+
}) : function(o, v) {
|
|
12
|
+
o["default"] = v;
|
|
13
|
+
});
|
|
14
|
+
var __importStar = (this && this.__importStar) || function (mod) {
|
|
15
|
+
if (mod && mod.__esModule) return mod;
|
|
16
|
+
var result = {};
|
|
17
|
+
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
18
|
+
__setModuleDefault(result, mod);
|
|
19
|
+
return result;
|
|
20
|
+
};
|
|
2
21
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.
|
|
22
|
+
exports.genTemplateInfoList = exports.onGenCommand = exports.hasYarn = exports.hasPnpm = void 0;
|
|
23
|
+
const path = __importStar(require("path"));
|
|
4
24
|
const child_process_1 = require("child_process");
|
|
5
25
|
const fs_1 = require("fs");
|
|
6
26
|
function hasPnpm() {
|
|
@@ -33,13 +53,18 @@ function onGenCommand() {
|
|
|
33
53
|
return 'npm';
|
|
34
54
|
}
|
|
35
55
|
exports.onGenCommand = onGenCommand;
|
|
36
|
-
function
|
|
37
|
-
const
|
|
56
|
+
function genTemplateInfoList(root) {
|
|
57
|
+
const temps = [];
|
|
38
58
|
fs_1.readdirSync(root, { withFileTypes: true }).forEach(o => {
|
|
59
|
+
const src = path.join(root, o.name);
|
|
39
60
|
if (o.isDirectory()) {
|
|
40
|
-
|
|
61
|
+
temps.push({
|
|
62
|
+
name: o.name,
|
|
63
|
+
src,
|
|
64
|
+
children: fs_1.existsSync(path.join(src, 'package.json')) ? [] : genTemplateInfoList(src)
|
|
65
|
+
});
|
|
41
66
|
}
|
|
42
67
|
});
|
|
43
|
-
return
|
|
68
|
+
return temps;
|
|
44
69
|
}
|
|
45
|
-
exports.
|
|
70
|
+
exports.genTemplateInfoList = genTemplateInfoList;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "create-packer",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.20.0",
|
|
4
4
|
"main": "index.js",
|
|
5
5
|
"repository": "https://github.com/kevily/create-packer",
|
|
6
6
|
"author": "1k <bug_zero@163.com>",
|
|
@@ -42,7 +42,7 @@
|
|
|
42
42
|
"scripts": {
|
|
43
43
|
"login": "npm login --registry https://registry.npmjs.org",
|
|
44
44
|
"pub": "pnpm run build && pnpm run push && node ./utils/pub.js",
|
|
45
|
-
"test": "pnpm run build && rimraf ./__test__ &&
|
|
45
|
+
"test": "pnpm run build && rimraf ./__test__ && node ./bin __test__",
|
|
46
46
|
"build": "rimraf ./bin && tsc",
|
|
47
47
|
"commit": "git add . && cz",
|
|
48
48
|
"push": "pnpm run commit && git push"
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { create, StoreApi as ZStoreApi } from 'zustand'
|
|
2
2
|
import { combine } from 'zustand/middleware'
|
|
3
3
|
import { produce } from 'immer'
|
|
4
|
-
import { forEach, size } from 'lodash-es'
|
|
4
|
+
import { forEach, isEqual, size } from 'lodash-es'
|
|
5
5
|
|
|
6
6
|
export type StoreApi<S> = Omit<ZStoreApi<S>, 'setState'> & {
|
|
7
7
|
setState: (updater: ((state: S) => void) | Partial<S>, replace?: boolean) => void
|
|
@@ -46,13 +46,12 @@ export function define<
|
|
|
46
46
|
combine(createDefState(), (set, get, store) => {
|
|
47
47
|
// getterListener
|
|
48
48
|
// ----------------------------------------------------------------------
|
|
49
|
-
store.subscribe(state => {
|
|
50
|
-
const oldGetterState: any = get()
|
|
49
|
+
store.subscribe((state, prevState) => {
|
|
51
50
|
let equalledLen = 0
|
|
52
51
|
const newGetterState: any = {}
|
|
53
52
|
forEach(options.getter(), (getter, k) => {
|
|
54
53
|
const value = getter(state)
|
|
55
|
-
if (value
|
|
54
|
+
if (isEqual(value, prevState[k])) {
|
|
56
55
|
equalledLen += 1
|
|
57
56
|
} else {
|
|
58
57
|
newGetterState[k] = getter(state)
|
|
@@ -10,7 +10,7 @@
|
|
|
10
10
|
"scripts": {
|
|
11
11
|
"login": "npm login --registry https://registry.npmjs.org",
|
|
12
12
|
"pub": "pnpm run build && pnpm run push && node ./utils/pub.js",
|
|
13
|
-
"test": "pnpm run build && rimraf ./__test__ &&
|
|
13
|
+
"test": "pnpm run build && rimraf ./__test__ && node ./bin __test__",
|
|
14
14
|
"build": "rimraf ./bin && tsc",
|
|
15
15
|
"commit": "git add . && cz",
|
|
16
16
|
"push": "pnpm run commit && git push"
|
|
@@ -1,27 +1,17 @@
|
|
|
1
1
|
import inquirer = require('inquirer')
|
|
2
2
|
import fsExtra = require('fs-extra')
|
|
3
3
|
import path = require('path')
|
|
4
|
-
import fs = require('fs')
|
|
5
4
|
import chalk = require('chalk')
|
|
6
5
|
import ora = require('ora')
|
|
7
6
|
import { spawnSync } from 'child_process'
|
|
8
|
-
import {
|
|
9
|
-
|
|
10
|
-
export interface tempInfoType {
|
|
11
|
-
name: string
|
|
12
|
-
src: string
|
|
13
|
-
}
|
|
7
|
+
import { genTemplateInfoList, onGenCommand } from './utils'
|
|
8
|
+
import { existsSync } from 'fs'
|
|
14
9
|
|
|
15
10
|
const cwd = process.cwd()
|
|
16
11
|
const command = onGenCommand()
|
|
17
12
|
const excludes = ['node_modules', 'yarn-error.log', 'dist']
|
|
18
13
|
const tempRoot = path.join(__dirname, '../../template')
|
|
19
|
-
const
|
|
20
|
-
return {
|
|
21
|
-
name,
|
|
22
|
-
src: path.join(tempRoot, name)
|
|
23
|
-
}
|
|
24
|
-
})
|
|
14
|
+
const tempInfoList = genTemplateInfoList(tempRoot)
|
|
25
15
|
|
|
26
16
|
function copyTempFile(tempPath, output) {
|
|
27
17
|
fsExtra.readdirSync(tempPath).map(name => {
|
|
@@ -39,23 +29,34 @@ function createTempEnd(output: string) {
|
|
|
39
29
|
|
|
40
30
|
export async function createTemp(dirname: string) {
|
|
41
31
|
const isCurrent = dirname === '.'
|
|
42
|
-
|
|
32
|
+
let answer = await inquirer.prompt([
|
|
43
33
|
{
|
|
44
34
|
type: 'list',
|
|
45
35
|
name: 'temp',
|
|
46
36
|
message: 'Select temp.',
|
|
47
|
-
choices:
|
|
37
|
+
choices: tempInfoList.map(o => o.name)
|
|
48
38
|
}
|
|
49
39
|
])
|
|
40
|
+
const tempInfo = tempInfoList.find(o => o.name === answer.temp)
|
|
41
|
+
if (tempInfo.children) {
|
|
42
|
+
answer = await inquirer.prompt([
|
|
43
|
+
{
|
|
44
|
+
type: 'list',
|
|
45
|
+
name: 'temp',
|
|
46
|
+
message: 'Select temp type.',
|
|
47
|
+
choices: tempInfo.children.map(o => o.name)
|
|
48
|
+
}
|
|
49
|
+
])
|
|
50
|
+
}
|
|
50
51
|
const creating = ora(chalk.yellow('Creating...\n')).start()
|
|
51
52
|
const output = path.join(cwd, isCurrent ? '' : dirname)
|
|
52
|
-
if (!isCurrent &&
|
|
53
|
+
if (!isCurrent && existsSync(output)) {
|
|
53
54
|
return console.log(chalk.red(`${dirname} already exists!`))
|
|
54
55
|
}
|
|
55
56
|
if (!isCurrent) {
|
|
56
57
|
fsExtra.mkdirSync(output)
|
|
57
58
|
}
|
|
58
|
-
const tempPath = path.join(tempRoot, temp)
|
|
59
|
+
const tempPath = path.join(tempRoot, answer.temp)
|
|
59
60
|
copyTempFile(tempPath, output)
|
|
60
61
|
createTempEnd(output)
|
|
61
62
|
creating.succeed()
|
|
@@ -1,9 +1,5 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
import { createTemp } from './
|
|
2
|
+
import { createTemp } from './createTemp'
|
|
3
3
|
import { program } from 'commander'
|
|
4
4
|
|
|
5
|
-
program
|
|
6
|
-
.option('-c, --create <dirname>', 'Create project.', dirname => {
|
|
7
|
-
return createTemp(dirname)
|
|
8
|
-
})
|
|
9
|
-
.parse(process.argv)
|
|
5
|
+
program.argument('<dirname>', 'Create project.', dirname => createTemp(dirname)).parse(process.argv)
|
|
@@ -1,5 +1,6 @@
|
|
|
1
|
+
import * as path from 'path'
|
|
1
2
|
import { execSync } from 'child_process'
|
|
2
|
-
import { readdirSync } from 'fs'
|
|
3
|
+
import { readdirSync, existsSync } from 'fs'
|
|
3
4
|
|
|
4
5
|
export function hasPnpm() {
|
|
5
6
|
try {
|
|
@@ -27,12 +28,22 @@ export function onGenCommand() {
|
|
|
27
28
|
return 'npm'
|
|
28
29
|
}
|
|
29
30
|
|
|
30
|
-
|
|
31
|
-
|
|
31
|
+
interface tempInfoType {
|
|
32
|
+
name: string
|
|
33
|
+
src: string
|
|
34
|
+
children?: tempInfoType[]
|
|
35
|
+
}
|
|
36
|
+
export function genTemplateInfoList(root: string) {
|
|
37
|
+
const temps: tempInfoType[] = []
|
|
32
38
|
readdirSync(root, { withFileTypes: true }).forEach(o => {
|
|
39
|
+
const src = path.join(root, o.name)
|
|
33
40
|
if (o.isDirectory()) {
|
|
34
|
-
|
|
41
|
+
temps.push({
|
|
42
|
+
name: o.name,
|
|
43
|
+
src,
|
|
44
|
+
children: existsSync(path.join(src, 'package.json')) ? [] : genTemplateInfoList(src)
|
|
45
|
+
})
|
|
35
46
|
}
|
|
36
47
|
})
|
|
37
|
-
return
|
|
48
|
+
return temps
|
|
38
49
|
}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { create, StoreApi as ZStoreApi } from 'zustand'
|
|
2
2
|
import { combine } from 'zustand/middleware'
|
|
3
3
|
import { produce } from 'immer'
|
|
4
|
-
import { forEach, size } from 'lodash-es'
|
|
4
|
+
import { forEach, isEqual, size } from 'lodash-es'
|
|
5
5
|
|
|
6
6
|
export type StoreApi<S> = Omit<ZStoreApi<S>, 'setState'> & {
|
|
7
7
|
setState: (updater: ((state: S) => void) | Partial<S>, replace?: boolean) => void
|
|
@@ -46,13 +46,12 @@ export function define<
|
|
|
46
46
|
combine(createDefState(), (set, get, store) => {
|
|
47
47
|
// getterListener
|
|
48
48
|
// ----------------------------------------------------------------------
|
|
49
|
-
store.subscribe(state => {
|
|
50
|
-
const oldGetterState: any = get()
|
|
49
|
+
store.subscribe((state, prevState) => {
|
|
51
50
|
let equalledLen = 0
|
|
52
51
|
const newGetterState: any = {}
|
|
53
52
|
forEach(options.getter(), (getter, k) => {
|
|
54
53
|
const value = getter(state)
|
|
55
|
-
if (value
|
|
54
|
+
if (isEqual(value, prevState[k])) {
|
|
56
55
|
equalledLen += 1
|
|
57
56
|
} else {
|
|
58
57
|
newGetterState[k] = getter(state)
|
|
@@ -0,0 +1,84 @@
|
|
|
1
|
+
{
|
|
2
|
+
"root": true,
|
|
3
|
+
"parser": "@typescript-eslint/parser",
|
|
4
|
+
"plugins": ["prettier"],
|
|
5
|
+
"extends": [
|
|
6
|
+
"eslint:recommended",
|
|
7
|
+
"plugin:@typescript-eslint/recommended",
|
|
8
|
+
"plugin:storybook/recommended",
|
|
9
|
+
"plugin:react/recommended",
|
|
10
|
+
"plugin:react-hooks/recommended",
|
|
11
|
+
"plugin:import/recommended",
|
|
12
|
+
"plugin:import/typescript",
|
|
13
|
+
],
|
|
14
|
+
"settings": {
|
|
15
|
+
"import/resolver": {
|
|
16
|
+
"typescript": true,
|
|
17
|
+
"node": true
|
|
18
|
+
},
|
|
19
|
+
"react": {
|
|
20
|
+
"version": "18"
|
|
21
|
+
}
|
|
22
|
+
},
|
|
23
|
+
"env": {
|
|
24
|
+
"browser": true,
|
|
25
|
+
"node": true,
|
|
26
|
+
"es6": true,
|
|
27
|
+
"jest": true
|
|
28
|
+
},
|
|
29
|
+
"parserOptions": {
|
|
30
|
+
"ecmaVersion": 2018,
|
|
31
|
+
"sourceType": "module",
|
|
32
|
+
"ecmaFeatures": {
|
|
33
|
+
"jsx": true
|
|
34
|
+
},
|
|
35
|
+
"useJSXTextNode": true
|
|
36
|
+
},
|
|
37
|
+
"rules": {
|
|
38
|
+
"import/export": "off",
|
|
39
|
+
"import/namespace": "off",
|
|
40
|
+
"import/order": [
|
|
41
|
+
"error",
|
|
42
|
+
{
|
|
43
|
+
"groups": [
|
|
44
|
+
"builtin",
|
|
45
|
+
"external",
|
|
46
|
+
"internal",
|
|
47
|
+
"parent",
|
|
48
|
+
"sibling",
|
|
49
|
+
"index",
|
|
50
|
+
"object",
|
|
51
|
+
"type"
|
|
52
|
+
]
|
|
53
|
+
}
|
|
54
|
+
],
|
|
55
|
+
"@typescript-eslint/no-var-requires": 0,
|
|
56
|
+
"@typescript-eslint/explicit-function-return-type": "off",
|
|
57
|
+
"@typescript-eslint/no-explicit-any": 0,
|
|
58
|
+
"@typescript-eslint/no-non-null-assertion": "off",
|
|
59
|
+
"@typescript-eslint/no-inferrable-types": [
|
|
60
|
+
"warn",
|
|
61
|
+
{
|
|
62
|
+
"ignoreParameters": true
|
|
63
|
+
}
|
|
64
|
+
],
|
|
65
|
+
"@typescript-eslint/no-unused-vars": ["warn", { "argsIgnorePattern": "^_" }],
|
|
66
|
+
"@typescript-eslint/member-delimiter-style": 0,
|
|
67
|
+
"@typescript-eslint/class-name-casing": 0,
|
|
68
|
+
"@typescript-eslint/explicit-module-boundary-types": "off",
|
|
69
|
+
"@typescript-eslint/ban-ts-comment": "off",
|
|
70
|
+
"@typescript-eslint/no-empty-interface": "off",
|
|
71
|
+
"react/prop-types": "off",
|
|
72
|
+
"react/no-find-dom-node": "off",
|
|
73
|
+
"react-hooks/exhaustive-deps": "warn",
|
|
74
|
+
"react/display-name": "off",
|
|
75
|
+
"react/react-in-jsx-scope": "off",
|
|
76
|
+
"prettier/prettier": [
|
|
77
|
+
"error",
|
|
78
|
+
{
|
|
79
|
+
"endOfLine": "auto"
|
|
80
|
+
}
|
|
81
|
+
],
|
|
82
|
+
"no-constant-condition": "off"
|
|
83
|
+
}
|
|
84
|
+
}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
# Logs
|
|
2
|
+
logs
|
|
3
|
+
*.log
|
|
4
|
+
npm-debug.log*
|
|
5
|
+
yarn-debug.log*
|
|
6
|
+
yarn-error.log*
|
|
7
|
+
pnpm-debug.log*
|
|
8
|
+
lerna-debug.log*
|
|
9
|
+
|
|
10
|
+
node_modules
|
|
11
|
+
dist
|
|
12
|
+
dist-ssr
|
|
13
|
+
*.local
|
|
14
|
+
types
|
|
15
|
+
|
|
16
|
+
# Editor directories and files
|
|
17
|
+
.vscode/*
|
|
18
|
+
!.vscode/extensions.json
|
|
19
|
+
.history
|
|
20
|
+
.idea
|
|
21
|
+
.DS_Store
|
|
22
|
+
*.suo
|
|
23
|
+
*.ntvs*
|
|
24
|
+
*.njsproj
|
|
25
|
+
*.sln
|
|
26
|
+
*.sw?
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
{
|
|
2
|
+
"overrides": [
|
|
3
|
+
{
|
|
4
|
+
"files": ".prettierrc",
|
|
5
|
+
"options": { "parser": "json" }
|
|
6
|
+
}
|
|
7
|
+
],
|
|
8
|
+
"printWidth": 100,
|
|
9
|
+
"tabWidth": 4,
|
|
10
|
+
"useTabs": false,
|
|
11
|
+
"semi": false,
|
|
12
|
+
"singleQuote": true,
|
|
13
|
+
"trailingComma": "none",
|
|
14
|
+
"bracketSpacing": true,
|
|
15
|
+
"bracketSameLine": false,
|
|
16
|
+
"arrowParens": "avoid",
|
|
17
|
+
"rangeStart": 0
|
|
18
|
+
}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import type { StorybookConfig } from '@storybook/react-vite'
|
|
2
|
+
const config: StorybookConfig = {
|
|
3
|
+
stories: ['../src/**/*.mdx', '../src/**/*.stories.@(js|jsx|ts|tsx)'],
|
|
4
|
+
addons: [
|
|
5
|
+
'@storybook/addon-links',
|
|
6
|
+
'@storybook/addon-essentials',
|
|
7
|
+
'@storybook/addon-interactions'
|
|
8
|
+
],
|
|
9
|
+
framework: {
|
|
10
|
+
name: '@storybook/react-vite',
|
|
11
|
+
options: {}
|
|
12
|
+
},
|
|
13
|
+
docs: {
|
|
14
|
+
autodocs: 'tag'
|
|
15
|
+
}
|
|
16
|
+
}
|
|
17
|
+
export default config
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import type { Preview } from '@storybook/react'
|
|
2
|
+
|
|
3
|
+
const preview: Preview = {
|
|
4
|
+
parameters: {
|
|
5
|
+
actions: { argTypesRegex: '^on[A-Z].*' },
|
|
6
|
+
controls: {
|
|
7
|
+
matchers: {
|
|
8
|
+
color: /(background|color)$/i,
|
|
9
|
+
date: /Date$/
|
|
10
|
+
}
|
|
11
|
+
}
|
|
12
|
+
}
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
export default preview
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
{
|
|
2
|
+
"extends": "stylelint-config-standard",
|
|
3
|
+
"rules": {
|
|
4
|
+
"comment-empty-line-before": "never",
|
|
5
|
+
"no-empty-source": null,
|
|
6
|
+
"alpha-value-notation": null,
|
|
7
|
+
"color-function-notation": null,
|
|
8
|
+
"no-descending-specificity": null,
|
|
9
|
+
"at-rule-no-unknown": [
|
|
10
|
+
true,
|
|
11
|
+
{
|
|
12
|
+
"ignoreAtRules": ["tailwind", "apply", "use"]
|
|
13
|
+
}
|
|
14
|
+
],
|
|
15
|
+
"selector-pseudo-class-no-unknown": [
|
|
16
|
+
true,
|
|
17
|
+
{
|
|
18
|
+
"ignorePseudoClasses": ["global"]
|
|
19
|
+
}
|
|
20
|
+
],
|
|
21
|
+
"selector-class-pattern": null
|
|
22
|
+
}
|
|
23
|
+
}
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "react",
|
|
3
|
+
"version": "1.0.0",
|
|
4
|
+
"description": "",
|
|
5
|
+
"main": "dist/index.js",
|
|
6
|
+
"types": "dist/index.d.ts",
|
|
7
|
+
"scripts": {
|
|
8
|
+
"test": "echo \"Error: no test specified\" && exit 1",
|
|
9
|
+
"storybook": "storybook dev -p 6006",
|
|
10
|
+
"build-storybook": "storybook build"
|
|
11
|
+
},
|
|
12
|
+
"keywords": [],
|
|
13
|
+
"author": "",
|
|
14
|
+
"license": "ISC",
|
|
15
|
+
"peerDependencies": {
|
|
16
|
+
"react": "18.2.0",
|
|
17
|
+
"react-dom": "18.2.0"
|
|
18
|
+
},
|
|
19
|
+
"devDependencies": {
|
|
20
|
+
"@storybook/addon-essentials": "7.0.24",
|
|
21
|
+
"@storybook/addon-interactions": "7.0.24",
|
|
22
|
+
"@storybook/addon-links": "7.0.24",
|
|
23
|
+
"@storybook/blocks": "7.0.24",
|
|
24
|
+
"@storybook/react": "7.0.24",
|
|
25
|
+
"@storybook/react-vite": "7.0.24",
|
|
26
|
+
"@storybook/testing-library": "0.0.14-next.2",
|
|
27
|
+
"@types/react": "18.2.14",
|
|
28
|
+
"@types/react-dom": "18.2.6",
|
|
29
|
+
"@typescript-eslint/eslint-plugin": "5.60.1",
|
|
30
|
+
"@typescript-eslint/parser": "5.60.1",
|
|
31
|
+
"eslint": "8.43.0",
|
|
32
|
+
"eslint-import-resolver-typescript": "3.5.5",
|
|
33
|
+
"eslint-plugin-import": "2.27.5",
|
|
34
|
+
"eslint-plugin-prettier": "4.2.1",
|
|
35
|
+
"eslint-plugin-react": "7.32.2",
|
|
36
|
+
"eslint-plugin-react-hooks": "4.6.0",
|
|
37
|
+
"eslint-plugin-storybook": "0.6.12",
|
|
38
|
+
"prettier": "2.8.8",
|
|
39
|
+
"prop-types": "15.8.1",
|
|
40
|
+
"react": "18.2.0",
|
|
41
|
+
"react-dom": "18.2.0",
|
|
42
|
+
"storybook": "7.0.24",
|
|
43
|
+
"stylelint": "15.9.0",
|
|
44
|
+
"stylelint-config-standard": "33.0.0",
|
|
45
|
+
"typescript": "5.1.3",
|
|
46
|
+
"vite": "4.3.9"
|
|
47
|
+
}
|
|
48
|
+
}
|