easy-soft-develop 1.0.2 → 2.0.82

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 (42) 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 +149 -0
  12. package/src/index.js +30 -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 +249 -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 +190 -0
  21. package/src/templates/prettier.template.js +133 -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 +443 -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 +75 -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/clean.js +0 -45
  37. package/src/commit.refresh.js +0 -40
  38. package/src/develop.assist.js +0 -110
  39. package/src/init.env.js +0 -146
  40. package/src/package.init.global.dependence.dev.js +0 -29
  41. package/src/package.tools.js +0 -32
  42. package/src/shell.js +0 -9
@@ -0,0 +1,67 @@
1
+ const { fileGlobalHeader } = require('./template.config');
2
+
3
+ const folderPath = './develop/config/git';
4
+
5
+ const attributeFileContent = `${fileGlobalHeader}
6
+ const content = \`*.js eol=lf
7
+ *.jsx eol=lf
8
+ *.json eol=lf
9
+ *.css eol=lf
10
+ *.less eol=lf
11
+ *.scss eol=lf
12
+ \`;
13
+
14
+ module.exports = {
15
+ content,
16
+ };
17
+ `;
18
+
19
+ const attributeFile = {
20
+ folderPath: `${folderPath}/template`,
21
+ fileName: 'attributes.content.js',
22
+ coverFile: true,
23
+ fileContent: attributeFileContent,
24
+ };
25
+
26
+ const ignoreFileContent = `${fileGlobalHeader}
27
+ const content = \`# See https://help.github.com/articles/ignoring-files/ for more about ignoring files.
28
+
29
+ # dependencies
30
+ **/node_modules
31
+
32
+ # ignore dir
33
+ **/dist
34
+ **/es
35
+ **/.umi
36
+ **/.umi-production
37
+ **/.idea
38
+ **/.history
39
+ **/.vs
40
+
41
+ # ignore file
42
+ *.log
43
+ *.d.ts
44
+ *.bak
45
+
46
+ # ignore special
47
+ rollup.config-*.cjs
48
+ yarn.lock
49
+ package-lock.json
50
+ pnpm-lock.yaml
51
+ .firebase
52
+ .eslintcache
53
+ \`;
54
+
55
+ module.exports = {
56
+ content,
57
+ };
58
+ `;
59
+
60
+ const ignoreFile = {
61
+ folderPath: `${folderPath}/template`,
62
+ fileName: 'ignore.content.js',
63
+ coverFile: false,
64
+ fileContent: ignoreFileContent,
65
+ };
66
+
67
+ module.exports = { attributeFile, ignoreFile };
@@ -0,0 +1,35 @@
1
+ const { fileGlobalHeader } = require('./template.config');
2
+
3
+ const folderPath = './develop/config/lint-staged';
4
+
5
+ const contentFileContent = `${fileGlobalHeader}
6
+ const content = \`{
7
+ "*.{md,json}": ["npx prettier --cache --write"],
8
+ "*.{js,jsx}": [
9
+ "npx eslint --ext .js,.jsx,.ts,.tsx",
10
+ "npx prettier --cache --write"
11
+ ],
12
+ "*.{css,less,scss}": [
13
+ "stylelint",
14
+ "npx prettier --cache --write"
15
+ ],
16
+ "*.{ts,tsx}": [
17
+ "npx eslint --ext .js,.jsx,.ts,.tsx",
18
+ "npx prettier --cache --parser=typescript --write"
19
+ ]
20
+ }
21
+ \`;
22
+
23
+ module.exports = {
24
+ content,
25
+ };
26
+ `;
27
+
28
+ const contentFile = {
29
+ folderPath: `${folderPath}/template`,
30
+ fileName: 'content.js',
31
+ coverFile: false,
32
+ fileContent: contentFileContent,
33
+ };
34
+
35
+ module.exports = { contentFile };
@@ -0,0 +1,190 @@
1
+ const { fileGlobalHeader } = require('./template.config');
2
+
3
+ const folderPath = './develop/config/package';
4
+
5
+ const globalChildPackageFileContent = `${fileGlobalHeader}
6
+ const lintScript = {
7
+ precommit: 'npm run z:lint:staged',
8
+ 'z:lint:file:all': 'npm run lint:script:all && npm run lint:style:all',
9
+ 'z:lint:file:all:fix': 'npm run lint:script:all:fix && npm run lint:style:all:fix',
10
+ 'z:lint:file:change': 'npm run lint:script:change && npm run lint:style:all',
11
+ 'z:lint:file:change:fix': 'npm run lint:script:change:fix && npm run lint:style:all:fix',
12
+ 'z:lint:script:all': 'npx eslint --ext .js,.jsx,.ts,.tsx ./src',
13
+ 'z:lint:script:all:fix': 'npx eslint --fix --ext .js,.jsx,.ts,.tsx ./src',
14
+ 'postz:lint:script:all:fix': 'npm run prettier:format:all',
15
+ 'z:lint:script:change': 'npx eslint --cache --ext .js,.jsx,.ts,.tsx ./src',
16
+ 'z:lint:script:change:fix': 'npx eslint --fix --cache --ext .js,.jsx,.ts,.tsx ./src && npm run lint:style:fix',
17
+ 'postz:lint:script:change:fix': 'npm run prettier:format:change',
18
+ 'z:lint:staged': 'npx lint-staged --quiet',
19
+ 'z:lint:style:all': 'npx stylelint "./src/**/*.less"',
20
+ 'z:lint:style:all:fix': 'npx stylelint --fix "./src/**/*.less"',
21
+ 'postz:lint:style:all:fix': 'npm run prettier:format:all',
22
+ 'z:lint:style:change': 'npx stylelint --cache "./src/**/*.less"',
23
+ 'z:lint:style:change:fix': 'npx stylelint --cache --fix "./src/**/*.less"',
24
+ 'postz:lint:style:change:fix': 'npm run prettier:format:change',
25
+ 'z:tsc:build': 'echo show tsc version and create declaration file && tsc -v && tsc -p ./tsconfig.types.json && echo declaration file generate complete',
26
+ };
27
+
28
+ const prettierScript = {
29
+ 'z:prettier:format:all': 'npx prettier --write .',
30
+ 'z:prettier:format:change': 'npx prettier --cache --write .',
31
+ 'z:prettier:package.json': 'npx prettier --write ./package.json',
32
+ };
33
+
34
+ module.exports = {
35
+ ...lintScript,
36
+ ...prettierScript,
37
+ };
38
+ `;
39
+
40
+ const globalChildPackageFile = {
41
+ folderPath: `${folderPath}/template`,
42
+ fileName: 'children.content.js',
43
+ coverFile: true,
44
+ fileContent: globalChildPackageFileContent,
45
+ };
46
+
47
+ const globalMainPackageFileContent = `${fileGlobalHeader}
48
+ const lintScript = {
49
+ 'z:lint:staged': 'npx lint-staged',
50
+ };
51
+
52
+ const prepareScript = {
53
+ prepare: 'npm run z:husky:install && echo do other prepare work with here',
54
+ 'z:husky:install':'npx husky install'
55
+ };
56
+
57
+ const toolsScript = {
58
+ postinstall: 'npm run z:initial:environment && echo do other postinstall work with here',
59
+ 'z:show:info':
60
+ 'echo node version && node --version && echo npm version && npm --version && echo ------------ && npx lerna ls -a -l',
61
+ "z:show:package": "npx lerna ls -a -l",
62
+ "z:sleep": "npx easy-soft-develop sleep --second 2 --showInfo false",
63
+ "z:create:assist-scripts": "npx easy-soft-develop create-assist-scripts",
64
+ };
65
+
66
+ const publishScript = {
67
+ changelog:
68
+ 'lerna version --conventional-commits --no-push --no-git-tag-version',
69
+ 'prez:publish-npm-all': 'npm run z:change:nrm:npm',
70
+ 'z:publish-npm-all': 'npm run z:publish:npm-all',
71
+ 'postz:publish-npm-all': 'npm run z:change:nrm:local',
72
+ 'prez:publish:lerna': 'npm run z:change:nrm:npm',
73
+ 'z:publish:lerna': 'lerna updated && npm run z:lerna:publish',
74
+ 'postz:publish:lerna': 'npm run z:change:nrm:local && npm run publish-npm-all',
75
+ 'prez:publish:build': 'npm run z:install && npm run cz && npm run z:build:all',
76
+ 'z:publish:build': 'npm run z:publish:lerna',
77
+ };
78
+
79
+ const cleanScript = {
80
+ "z:clean": "node ./develop/assists/clean.js",
81
+ };
82
+
83
+ const environmentScript = {
84
+ "prez:initial:environment": "npm run z:create:assist-scripts",
85
+ "z:initial:environment": "node ./develop/assists/initial.environment.js",
86
+ };
87
+
88
+ const lernaScript = {
89
+ 'z:lerna:publish': 'lerna publish --yes',
90
+ 'prez:lerna:bootstrap': 'npm run z:change:nrm:local',
91
+ 'z:lerna:bootstrap':
92
+ 'npm run z:clean && npm run z:husky:install && git pull && npm run z:install',
93
+ };
94
+
95
+ const installScript = {
96
+ "z:reinstall": 'npm run z:lerna:bootstrap',
97
+ "postinstall": "npm run z:initial:environment",
98
+ "z:install.global.develop.dependence": "node ./develop/assists/install.global.develop.dependence",
99
+ "postz:install.global.develop.dependence": "npm run z:install",
100
+ "z:install": "pnpm install",
101
+ };
102
+
103
+ const nrmScript = {
104
+ "z:change:nrm:local": "nrm use local",
105
+ "z:change:nrm:npm": "nrm use npm",
106
+ };
107
+
108
+ const commitScript = {
109
+ commitlint: 'npx commitlint --edit',
110
+ precz: 'npm run z:commit:refresh && git stage -A',
111
+ cz: 'cz',
112
+ postcz: 'git push',
113
+ precommit: 'npm run z:lint:staged',
114
+ "z:commit:refresh": "npx easy-soft-develop commit-refresh",
115
+ };
116
+
117
+ const prettierScript = {
118
+ "z:prettier:format:all": "npx prettier --write .",
119
+ "z:prettier:format:change": "npx prettier --cache --write .",
120
+ "z:prettier:package.json:all": "npx prettier --write ./**/package.json",
121
+ "z:prettier:package.json:current": "npx prettier --write ./package.json",
122
+ };
123
+
124
+ const ncuScript = {
125
+ 'z:check:all-package-version': 'npx easy-soft-develop check-all-package-version',
126
+ 'z:update:all-package-version': 'npx easy-soft-develop update-all-package-version',
127
+ 'postz:update:all-package-version': 'npm run z:install',
128
+ 'z:update:special-package-version': 'node ./develop/assists/package.update.special.version.js',
129
+ 'postz:update:special-package-version': 'npm run z:install',
130
+ };
131
+
132
+ module.exports = {
133
+ ...lintScript,
134
+ ...prettierScript,
135
+ ...prepareScript,
136
+ ...toolsScript,
137
+ ...publishScript,
138
+ ...cleanScript,
139
+ ...environmentScript,
140
+ ...lernaScript,
141
+ ...installScript,
142
+ ...nrmScript,
143
+ ...commitScript,
144
+ ...ncuScript,
145
+ };
146
+ `;
147
+
148
+ const globalMainPackageFile = {
149
+ folderPath: `${folderPath}/template`,
150
+ fileName: 'main.content.js',
151
+ coverFile: true,
152
+ fileContent: globalMainPackageFileContent,
153
+ };
154
+
155
+ const customMainPackageFileContent = `${fileGlobalHeader}
156
+ const scripts = {};
157
+
158
+ module.exports = {
159
+ ...scripts,
160
+ };
161
+ `;
162
+
163
+ const customMainPackageFile = {
164
+ folderPath: `${folderPath}/custom`,
165
+ fileName: 'main.content.js',
166
+ coverFile: false,
167
+ fileContent: customMainPackageFileContent,
168
+ };
169
+
170
+ const customChildPackageFileContent = `${fileGlobalHeader}
171
+ const scripts = {};
172
+
173
+ module.exports = {
174
+ ...scripts,
175
+ };
176
+ `;
177
+
178
+ const customChildPackageFile = {
179
+ folderPath: `${folderPath}/custom`,
180
+ fileName: 'children.content.js',
181
+ coverFile: false,
182
+ fileContent: customChildPackageFileContent,
183
+ };
184
+
185
+ module.exports = {
186
+ globalChildPackageFile,
187
+ globalMainPackageFile,
188
+ customMainPackageFile,
189
+ customChildPackageFile,
190
+ };
@@ -0,0 +1,133 @@
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
+ .prettierrc.js
99
+ .eslintignore
100
+ .stylelintignore
101
+ .gitattributes
102
+ .browserslistrc
103
+ .dockerignore
104
+ .gitignore
105
+ .prettierignore
106
+ .eslintcache
107
+ .npmrc
108
+ .editorconfig
109
+ .czrc
110
+ .ga
111
+ rollup.config-*.cjs
112
+ pnpm-lock.yaml
113
+ CNAME
114
+ LICENSE
115
+ \`;
116
+
117
+ module.exports = {
118
+ content,
119
+ };
120
+ `;
121
+
122
+ const ignoreFile = {
123
+ folderPath: `${folderPath}/template`,
124
+ fileName: 'ignore.content.js',
125
+ coverFile: false,
126
+ fileContent: ignoreFileContent,
127
+ };
128
+
129
+ module.exports = {
130
+ ignoreFile,
131
+ contentFile,
132
+ configFile,
133
+ };
@@ -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 };