easy-soft-develop 1.0.2 → 2.0.110

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.
Files changed (43) hide show
  1. package/bin/cli.js +96 -3
  2. package/package.json +32 -22
  3. package/src/cliCollection/check-all-package-version.js +5 -0
  4. package/src/cliCollection/clear-all-dependence.js +39 -0
  5. package/src/cliCollection/commit-refresh.js +12 -0
  6. package/src/cliCollection/create-assist-scripts.cli.js +19 -0
  7. package/src/cliCollection/create-lerna-project.js +9 -0
  8. package/src/cliCollection/create-project-with-template.js +61 -0
  9. package/src/cliCollection/sleep.js +9 -0
  10. package/src/cliCollection/update-all-package-version.js +5 -0
  11. package/src/cliCollection/update-package-from-package.js +17 -0
  12. package/src/index.js +34 -22
  13. package/src/project/initProject.js +258 -0
  14. package/src/templates/babel.config.template.js +21 -0
  15. package/src/templates/commitlint.config.template.js +124 -0
  16. package/src/templates/editor.template.js +36 -0
  17. package/src/templates/eslint.template.js +511 -0
  18. package/src/templates/git.template.js +67 -0
  19. package/src/templates/lint-staged.template.js +35 -0
  20. package/src/templates/package.template.js +205 -0
  21. package/src/templates/prettier.template.js +132 -0
  22. package/src/templates/stylelint.template.js +79 -0
  23. package/src/templates/template.config.js +8 -0
  24. package/src/tools/clean.js +50 -0
  25. package/src/tools/commit.refresh.js +40 -0
  26. package/src/tools/develop.file.js +522 -0
  27. package/src/tools/initial.environment.js +118 -0
  28. package/src/tools/meta.js +242 -0
  29. package/src/tools/package.install.global.develop.dependence.js +92 -0
  30. package/src/tools/package.script.js +72 -0
  31. package/src/tools/package.tools.js +33 -0
  32. package/src/{package.update.js → tools/package.update.js} +16 -11
  33. package/src/tools/prettier.file.js +11 -0
  34. package/src/tools/prettier.package.json.js +17 -0
  35. package/src/{sleep.js → tools/sleep.js} +6 -3
  36. package/src/tools/update.package.from.package.js +153 -0
  37. package/src/clean.js +0 -45
  38. package/src/commit.refresh.js +0 -40
  39. package/src/develop.assist.js +0 -110
  40. package/src/init.env.js +0 -146
  41. package/src/package.init.global.dependence.dev.js +0 -29
  42. package/src/package.tools.js +0 -32
  43. package/src/shell.js +0 -9
@@ -0,0 +1,205 @@
1
+ const { fileGlobalHeader } = require('./template.config');
2
+
3
+ const folderPath = './develop/config/package';
4
+
5
+ const globalChildPackageFileContent = `${fileGlobalHeader}
6
+ const commitScript = {
7
+ precommit: 'npm run z:lint:staged',
8
+ };
9
+
10
+ const documentationScript = {
11
+ 'prez:documentation:generate': 'npx rimraf ./docs && npm run z:documentation:lint',
12
+ 'z:documentation:generate': 'npx documentation build src/** -f html --github -o docs',
13
+ 'z:documentation:lint': 'npx documentation lint src/**',
14
+ };
15
+
16
+ const lintScript = {
17
+ 'z:lint:file:all': 'npm run z:lint:script:all && npm run z:lint:style:all',
18
+ 'z:lint:file:all:fix': 'npm run z:lint:script:all:fix && npm run z:lint:style:all:fix',
19
+ 'z:lint:file:change': 'npm run z:lint:script:change && npm run z:lint:style:all',
20
+ 'z:lint:file:change:fix': 'npm run z:lint:script:change:fix && npm run z:lint:style:all:fix',
21
+ 'z:lint:script:all': 'npx eslint --ext .js,.jsx,.ts,.tsx ./src',
22
+ 'z:lint:script:all:fix': 'npx eslint --fix --ext .js,.jsx,.ts,.tsx ./src',
23
+ 'postz:lint:script:all:fix': 'npm run z:prettier:format:all',
24
+ 'z:lint:script:change': 'npx eslint --cache --ext .js,.jsx,.ts,.tsx ./src',
25
+ 'z:lint:script:change:fix': 'npx eslint --fix --cache --ext .js,.jsx,.ts,.tsx ./src && npm run z:lint:style:fix',
26
+ 'postz:lint:script:change:fix': 'npm run prettier:format:change',
27
+ 'z:lint:staged': 'npx lint-staged --quiet',
28
+ 'z:lint:style:all': 'npx stylelint "./src/**/*.less"',
29
+ 'z:lint:style:all:fix': 'npx stylelint --fix "./src/**/*.less"',
30
+ 'postz:lint:style:all:fix': 'npm run z:prettier:format:all',
31
+ 'z:lint:style:change': 'npx stylelint --cache "./src/**/*.less"',
32
+ 'z:lint:style:change:fix': 'npx stylelint --cache --fix "./src/**/*.less"',
33
+ 'postz:lint:style:change:fix': 'npm run prettier:format:change',
34
+ };
35
+
36
+ const prettierScript = {
37
+ 'z:prettier:format:all': 'npx prettier --write .',
38
+ 'z:prettier:format:change': 'npx prettier --cache --write .',
39
+ 'z:prettier:package.json': 'npx prettier --write ./package.json',
40
+ };
41
+
42
+ const tscScript = {
43
+ 'z:tsc:build': 'echo show tsc version and create declaration file && tsc -v && tsc -p ./tsconfig.types.json && echo declaration file generate complete',
44
+ };
45
+
46
+ module.exports = {
47
+ ...commitScript,
48
+ ...lintScript,
49
+ ...prettierScript,
50
+ ...tscScript,
51
+ };
52
+ `;
53
+
54
+ const globalChildPackageFile = {
55
+ folderPath: `${folderPath}/template`,
56
+ fileName: 'children.content.js',
57
+ coverFile: true,
58
+ fileContent: globalChildPackageFileContent,
59
+ };
60
+
61
+ const globalMainPackageFileContent = `${fileGlobalHeader}
62
+ const lintScript = {
63
+ 'z:lint:staged': 'npx lint-staged',
64
+ };
65
+
66
+ const prepareScript = {
67
+ prepare: 'npm run z:husky:install && echo do other prepare work with here',
68
+ 'z:husky:install':'npx husky install'
69
+ };
70
+
71
+ const toolsScript = {
72
+ postinstall: 'npm run z:initial:environment && echo do other postinstall work with here',
73
+ 'z:show:info':
74
+ 'echo node version && node --version && echo npm version && npm --version && echo ------------ && npx lerna ls -a -l',
75
+ "z:show:package": "npx lerna ls -a -l",
76
+ "z:sleep": "npx easy-soft-develop sleep --second 2 --showInfo false",
77
+ "z:create:assist-scripts": "npx easy-soft-develop create-assist-scripts",
78
+ "z:update:package-from-package": "node ./develop/assists/update-package-from-package.js",
79
+ };
80
+
81
+ const publishScript = {
82
+ changelog:
83
+ 'lerna version --conventional-commits --no-push --no-git-tag-version',
84
+ 'prez:publish-npm-all': 'npm run z:change:nrm:npm',
85
+ 'z:publish-npm-all': 'npm run z:publish:npm-all',
86
+ 'postz:publish-npm-all': 'npm run z:change:nrm:local',
87
+ 'prez:publish:lerna': 'npm run z:change:nrm:npm',
88
+ 'z:publish:lerna': 'lerna updated && npm run z:lerna:publish',
89
+ 'postz:publish:lerna': 'npm run z:change:nrm:local && npm run z:publish-npm-all',
90
+ 'prez:publish:build': 'npm run z:install && npm run cz && npm run z:build:all',
91
+ 'z:publish:build': 'npm run z:publish:lerna',
92
+ };
93
+
94
+ const cleanScript = {
95
+ "z:clean": "node ./develop/assists/clean.js",
96
+ };
97
+
98
+ const environmentScript = {
99
+ "prez:initial:environment": "npm run z:create:assist-scripts",
100
+ "z:initial:environment": "node ./develop/assists/initial.environment.js",
101
+ };
102
+
103
+ const lernaScript = {
104
+ 'z:lerna:publish': 'lerna publish --yes',
105
+ 'prez:lerna:bootstrap': 'npm run z:change:nrm:local',
106
+ 'z:lerna:bootstrap':
107
+ 'npm run z:clean && npm run z:husky:install && git pull && npm run z:install',
108
+ };
109
+
110
+ const installScript = {
111
+ "z:reinstall": 'npm run z:lerna:bootstrap',
112
+ "postinstall": "npm run z:initial:environment",
113
+ "z:install.global.develop.dependence": "node ./develop/assists/install.global.develop.dependence",
114
+ "postz:install.global.develop.dependence": "npm run z:install",
115
+ "z:install": "pnpm install",
116
+ };
117
+
118
+ const nrmScript = {
119
+ "z:change:nrm:local": "nrm use local",
120
+ "z:change:nrm:npm": "nrm use npm",
121
+ };
122
+
123
+ const commitScript = {
124
+ commitlint: 'npx commitlint --edit',
125
+ precz: 'npm run z:commit:refresh && git stage -A',
126
+ cz: 'cz',
127
+ postcz: 'git push',
128
+ precommit: 'npm run z:lint:staged',
129
+ "z:commit:refresh": "npx easy-soft-develop commit-refresh",
130
+ };
131
+
132
+ const prettierScript = {
133
+ "z:prettier:format:all": "npx prettier --write .",
134
+ "z:prettier:format:change": "npx prettier --cache --write .",
135
+ "z:prettier:package.json:all": "npx prettier --write ./**/package.json",
136
+ "z:prettier:package.json:current": "npx prettier --write ./package.json",
137
+ };
138
+
139
+ const ncuScript = {
140
+ 'z:check:all-package-version': 'npx easy-soft-develop check-all-package-version',
141
+ 'z:update:all-package-version': 'npx easy-soft-develop update-all-package-version',
142
+ 'postz:update:all-package-version': 'npm run z:install',
143
+ 'z:update:special-package-version': 'node ./develop/assists/package.update.special.version.js',
144
+ 'postz:update:special-package-version': 'npm run z:install',
145
+ };
146
+
147
+ module.exports = {
148
+ ...lintScript,
149
+ ...prettierScript,
150
+ ...prepareScript,
151
+ ...toolsScript,
152
+ ...publishScript,
153
+ ...cleanScript,
154
+ ...environmentScript,
155
+ ...lernaScript,
156
+ ...installScript,
157
+ ...nrmScript,
158
+ ...commitScript,
159
+ ...ncuScript,
160
+ };
161
+ `;
162
+
163
+ const globalMainPackageFile = {
164
+ folderPath: `${folderPath}/template`,
165
+ fileName: 'main.content.js',
166
+ coverFile: true,
167
+ fileContent: globalMainPackageFileContent,
168
+ };
169
+
170
+ const customMainPackageFileContent = `${fileGlobalHeader}
171
+ const scripts = {};
172
+
173
+ module.exports = {
174
+ ...scripts,
175
+ };
176
+ `;
177
+
178
+ const customMainPackageFile = {
179
+ folderPath: `${folderPath}/custom`,
180
+ fileName: 'main.content.js',
181
+ coverFile: false,
182
+ fileContent: customMainPackageFileContent,
183
+ };
184
+
185
+ const customChildPackageFileContent = `${fileGlobalHeader}
186
+ const scripts = {};
187
+
188
+ module.exports = {
189
+ ...scripts,
190
+ };
191
+ `;
192
+
193
+ const customChildPackageFile = {
194
+ folderPath: `${folderPath}/custom`,
195
+ fileName: 'children.content.js',
196
+ coverFile: false,
197
+ fileContent: customChildPackageFileContent,
198
+ };
199
+
200
+ module.exports = {
201
+ globalChildPackageFile,
202
+ globalMainPackageFile,
203
+ customMainPackageFile,
204
+ customChildPackageFile,
205
+ };
@@ -0,0 +1,132 @@
1
+ const { fileGlobalHeader } = require('./template.config');
2
+
3
+ const folderPath = './develop/config/prettier';
4
+
5
+ const configFileContent = `${fileGlobalHeader}
6
+ module.exports = {
7
+ generalConfig: {
8
+ pluginSearchDirs: false,
9
+ printWidth: 80,
10
+ singleQuote: true,
11
+ trailingComma: 'all',
12
+ proseWrap: 'never',
13
+ semi: true,
14
+ overrides: [
15
+ {
16
+ files: '.prettierrc',
17
+ options: {
18
+ parser: 'json',
19
+ },
20
+ },
21
+ ],
22
+ plugins: [
23
+ // 'prettier-plugin-organize-imports',
24
+ 'prettier-plugin-packagejson',
25
+ ],
26
+ },
27
+ };
28
+ `;
29
+
30
+ const configFile = {
31
+ folderPath: `${folderPath}/config`,
32
+ fileName: 'index.js',
33
+ coverFile: true,
34
+ fileContent: configFileContent,
35
+ };
36
+
37
+ const contentFileContent = `${fileGlobalHeader}
38
+ const mainContent = \`${fileGlobalHeader}
39
+ const { generalConfig } = require('./develop/config/prettier/config');
40
+
41
+ module.exports = generalConfig;
42
+ \`;
43
+
44
+ const packageContent = \`${fileGlobalHeader}
45
+ var { generalConfig } = require("../../develop/config/prettier/config");
46
+
47
+ module.exports = generalConfig;
48
+ \`;
49
+
50
+ module.exports = {
51
+ mainContent,
52
+ packageContent,
53
+ };
54
+ `;
55
+
56
+ const contentFile = {
57
+ folderPath: `${folderPath}/template`,
58
+ fileName: 'content.js',
59
+ coverFile: true,
60
+ fileContent: contentFileContent,
61
+ };
62
+
63
+ const ignoreFileContent = `${fileGlobalHeader}
64
+ const content = \`# ignore dir
65
+ **/node_modules/**
66
+ **/templates/**
67
+ **/lib/**
68
+ **/dist/**
69
+ **/es/**
70
+ **/.umi/**
71
+ **/.umi-production/**
72
+ **/.idea/**
73
+ **/.ga/**
74
+ **/.history/**
75
+ **/.husky/**
76
+ **/.vs/**
77
+
78
+ # ignore file
79
+ *.png
80
+ *.jpg
81
+ *.jpeg
82
+ *.rar
83
+ *.zip
84
+ *.7z
85
+ *.ico
86
+ *.gif
87
+ *.toml
88
+ *.lock
89
+ *.tar.gz
90
+ *.log
91
+ *.txt
92
+ *.text
93
+ *.ejs
94
+ *.svg
95
+ *.min.js
96
+
97
+ # ignore special
98
+ .eslintignore
99
+ .stylelintignore
100
+ .gitattributes
101
+ .browserslistrc
102
+ .dockerignore
103
+ .gitignore
104
+ .prettierignore
105
+ .eslintcache
106
+ .npmrc
107
+ .editorconfig
108
+ .czrc
109
+ .ga
110
+ rollup.config-*.cjs
111
+ pnpm-lock.yaml
112
+ CNAME
113
+ LICENSE
114
+ \`;
115
+
116
+ module.exports = {
117
+ content,
118
+ };
119
+ `;
120
+
121
+ const ignoreFile = {
122
+ folderPath: `${folderPath}/template`,
123
+ fileName: 'ignore.content.js',
124
+ coverFile: false,
125
+ fileContent: ignoreFileContent,
126
+ };
127
+
128
+ module.exports = {
129
+ ignoreFile,
130
+ contentFile,
131
+ configFile,
132
+ };
@@ -0,0 +1,79 @@
1
+ const { fileGlobalHeader } = require('./template.config');
2
+
3
+ const folderPath = './develop/config/stylelint';
4
+
5
+ const configFileContent = `${fileGlobalHeader}
6
+ module.exports = {
7
+ generalConfig: {
8
+ extends: [
9
+ 'stylelint-config-standard',
10
+ 'stylelint-config-css-modules',
11
+ 'stylelint-config-prettier',
12
+ ],
13
+ plugins: ['stylelint-declaration-block-no-ignored-properties'],
14
+ ignoreFiles: ['**/*.js', '**/*.jsx', '**/*.tsx', '**/*.ts'],
15
+ customSyntax: 'postcss-less',
16
+ rules: {
17
+ 'function-url-quotes': 'always',
18
+ 'selector-attribute-quotes': 'always',
19
+ 'font-family-no-missing-generic-family-keyword': null,
20
+ 'plugin/declaration-block-no-ignored-properties': true,
21
+ 'selector-type-no-unknown': null,
22
+ 'value-keyword-case': ['lower', { ignoreProperties: ['composes'] }],
23
+ 'unicode-bom': 'never',
24
+ 'no-descending-specificity': null,
25
+ 'selector-class-pattern': null,
26
+ 'value-no-vendor-prefix': null,
27
+ 'color-function-notation': null,
28
+ },
29
+ },
30
+ };
31
+ `;
32
+
33
+ const configFile = {
34
+ folderPath: `${folderPath}/config`,
35
+ fileName: 'index.js',
36
+ coverFile: true,
37
+ fileContent: configFileContent,
38
+ };
39
+
40
+ const contentFileContent = `${fileGlobalHeader}
41
+ const mainContent = \`${fileGlobalHeader}
42
+ const { generalConfig } = require('./develop/config/stylelint/config');
43
+
44
+ module.exports = generalConfig;
45
+ \`;
46
+
47
+ const packageContent = \`${fileGlobalHeader}
48
+ const { generalConfig } = require('../../develop/config/stylelint/config');
49
+
50
+ module.exports = generalConfig;
51
+ \`;
52
+
53
+ module.exports = {
54
+ mainContent,
55
+ packageContent,
56
+ };
57
+ `;
58
+
59
+ const contentFile = {
60
+ folderPath: `${folderPath}/template`,
61
+ fileName: 'content.js',
62
+ coverFile: true,
63
+ fileContent: contentFileContent,
64
+ };
65
+
66
+ const ignoreFile = {
67
+ folderPath: `${folderPath}/template`,
68
+ fileName: 'ignore.content.js',
69
+ coverFile: false,
70
+ fileContent: `${fileGlobalHeader}
71
+ const content = \`\`;
72
+
73
+ module.exports = {
74
+ content,
75
+ };
76
+ `,
77
+ };
78
+
79
+ module.exports = { ignoreFile, contentFile, configFile };
@@ -0,0 +1,8 @@
1
+ const fileGlobalHeader = `/* eslint-disable no-undef */
2
+ /* eslint-disable unicorn/prefer-module */
3
+ /* eslint-disable no-useless-escape */
4
+ `;
5
+
6
+ module.exports = {
7
+ fileGlobalHeader,
8
+ };
@@ -0,0 +1,50 @@
1
+ const {
2
+ promptEmptyLine,
3
+ promptInfo,
4
+ promptSuccess,
5
+ promptError,
6
+ exec,
7
+ } = require('./meta');
8
+ const { loopPackage } = require('./package.tools');
9
+
10
+ function adjustMainPackageJson(command) {
11
+ exec(command);
12
+ }
13
+
14
+ function adjustChildrenPackageJson(command) {
15
+ loopPackage(({ name }) => {
16
+ exec(`cd ./packages/${name} && ${command}`);
17
+ });
18
+ }
19
+
20
+ function clean(preCmd, ...targets) {
21
+ try {
22
+ const list = targets.push('node_modules');
23
+
24
+ const command = list
25
+ .map((o) => {
26
+ if (o) {
27
+ return `npx rimraf ./${o}`;
28
+ }
29
+ return '';
30
+ })
31
+ .join(' && ');
32
+
33
+ promptInfo(`clean start`);
34
+ promptEmptyLine();
35
+
36
+ if (preCmd) {
37
+ exec(preCmd);
38
+ }
39
+
40
+ adjustChildrenPackageJson(command);
41
+
42
+ adjustMainPackageJson(command);
43
+
44
+ promptSuccess('clean success');
45
+ } catch (error) {
46
+ promptError(error);
47
+ }
48
+ }
49
+
50
+ module.exports = { clean };
@@ -0,0 +1,40 @@
1
+ const {
2
+ checkStringIsEmpty,
3
+ resolvePath,
4
+ writeFileSync,
5
+ mkdirSync,
6
+ promptSuccess,
7
+ } = require('./meta');
8
+
9
+ function commitRefresh(fileName = '', relativeFolder = '') {
10
+ const fileNameAdjust = checkStringIsEmpty(fileName)
11
+ ? 'commit.flag.json'
12
+ : fileName;
13
+ const relativeFolderAdjust = checkStringIsEmpty(relativeFolder)
14
+ ? 'develop/flags'
15
+ : relativeFolder;
16
+
17
+ const now = new Date();
18
+
19
+ const datetime = `${now.getFullYear()}-${
20
+ now.getMonth() + 1
21
+ }-${now.getDate()} ${now.getHours()}:${now.getMinutes()}:${now.getSeconds()}`;
22
+
23
+ let content = JSON.stringify({
24
+ datetime: datetime,
25
+ });
26
+
27
+ const filePath = resolvePath('.');
28
+
29
+ mkdirSync(`${filePath}/${relativeFolderAdjust}/`, { recursive: true });
30
+
31
+ const scriptFilePath = `${filePath}/${relativeFolderAdjust}/${fileNameAdjust}`;
32
+
33
+ writeFileSync(scriptFilePath, content);
34
+
35
+ const log = `${fileNameAdjust} refresh success in folder "./${relativeFolderAdjust}/"`;
36
+
37
+ promptSuccess(log);
38
+ }
39
+
40
+ module.exports = { commitRefresh };