@cocreate/cli 1.28.4 → 1.29.1

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/.github/FUNDING.yml +3 -3
  2. package/.github/workflows/automated.yml +55 -55
  3. package/CHANGELOG.md +20 -0
  4. package/CONTRIBUTING.md +96 -96
  5. package/CoCreate.config.js +26 -26
  6. package/LICENSE +21 -21
  7. package/README.md +76 -76
  8. package/docs/index.html +242 -67
  9. package/package.json +1 -1
  10. package/release.config.js +21 -21
  11. package/repositories.js +475 -475
  12. package/src/addMeta.js +74 -74
  13. package/src/coc.js +80 -80
  14. package/src/commands/bump.js +85 -85
  15. package/src/commands/clone.js +2 -2
  16. package/src/commands/fs/automated.js +141 -141
  17. package/src/commands/fs/bump.js +74 -74
  18. package/src/commands/fs/config.js +78 -78
  19. package/src/commands/fs/contribution.js +136 -136
  20. package/src/commands/fs/gitignore.js +40 -40
  21. package/src/commands/fs/icon-extract.js +31 -31
  22. package/src/commands/fs/manual.js +91 -91
  23. package/src/commands/fs/package.js +39 -39
  24. package/src/commands/fs/readme.js +138 -138
  25. package/src/commands/fs/remove.js +28 -28
  26. package/src/commands/fs/replace.js +42 -42
  27. package/src/commands/fs/webpack.js +191 -191
  28. package/src/commands/git/gitConfig.js +70 -70
  29. package/src/commands/gitConfig.js +72 -72
  30. package/src/commands/install.js +24 -24
  31. package/src/commands/link.js +107 -107
  32. package/src/commands/nginx.js +25 -25
  33. package/src/commands/other/add.js +63 -63
  34. package/src/commands/other/config.sh +4 -4
  35. package/src/commands/other/nginxConfigManager.js +137 -137
  36. package/src/commands/other/nodeCertManager.js +147 -147
  37. package/src/commands/other/symlinkPwa.js +38 -38
  38. package/src/commands/other/test.js +43 -43
  39. package/src/commands/other/updateModules.js +50 -50
  40. package/src/commands/symlink.js +113 -111
  41. package/src/execute.js +66 -66
  42. package/src/spawn.js +9 -9
  43. package/webpack.config.js +84 -84
package/src/addMeta.js CHANGED
@@ -1,75 +1,75 @@
1
- const fs = require('fs')
2
- const path = require("path")
3
- const util = require('node:util');
4
- const exec = util.promisify(require('node:child_process').exec);
5
-
6
- module.exports = async function addMeta(repos, failed, directory) {
7
- let packageManager;
8
- for (let i = 0; i < repos.length; i++) {
9
- repos[i].name = path.basename(repos[i].path);
10
- repos[i].plainName = repos[i].name.substring(9);
11
-
12
- if (directory) {
13
- repos[i].absolutePath = path.resolve(directory, repos[i].path);
14
- const parsedPath = path.parse(repos[i].absolutePath);
15
- repos[i].directory = parsedPath.dir
16
- }
17
-
18
- let packagejson = path.resolve(repos[i].absolutePath, 'package.json');
19
- if (!fs.existsSync(packagejson)) {
20
- console.error('package json not found for', repos[i].name);
21
- failed.push({
22
- name: repos[i].name,
23
- des: 'package json not found'
24
- })
25
- } else {
26
-
27
- let packageObj
28
- try {
29
- packageObj = require(packagejson);
30
- }
31
- catch (err) {
32
- console.error('packageObj', err.message)
33
- }
34
-
35
-
36
- repos[i].packageName = packageObj.name;
37
-
38
- repos[i].deps = Object.keys(packageObj['dependencies'] || {})
39
- .filter(packageName => packageName.startsWith('@cocreate/'));
40
- repos[i].devDeps = Object.keys(packageObj['devDependencies'] || {})
41
- .filter(packageName => packageName.startsWith('@cocreate/'));
42
-
43
- if (!repos[i].packageManager) {
44
- if (packageManager)
45
- repos[i].packageManager = packageManager
46
- else {
47
- repos[i].packageManager = 'npm'
48
- let lockFile = path.resolve(repos[i].absolutePath, 'package-lock.json');
49
- if (!fs.existsSync(lockFile)) {
50
- lockFile = path.resolve(repos[i].absolutePath, 'pnpm-lock.yaml');
51
- if (fs.existsSync(lockFile))
52
- repos[i].packageManager = 'pnpm'
53
- else {
54
- lockFile = path.resolve(repos[i].absolutePath, 'yarn.lock');
55
- if (fs.existsSync(lockFile))
56
- repos[i].packageManager = 'yarn'
57
- else {
58
- try {
59
- const { error } = await exec('yarn --version');
60
- if (!error)
61
- repos[i].packageManager = 'yarn'
62
- } catch(e) {
63
-
64
- }
65
- }
66
- }
67
- packageManager = repos[i].packageManager
68
- }
69
- }
70
- }
71
- }
72
- }
73
-
74
- return repos
1
+ const fs = require('fs')
2
+ const path = require("path")
3
+ const util = require('node:util');
4
+ const exec = util.promisify(require('node:child_process').exec);
5
+
6
+ module.exports = async function addMeta(repos, failed, directory) {
7
+ let packageManager;
8
+ for (let i = 0; i < repos.length; i++) {
9
+ repos[i].name = path.basename(repos[i].path);
10
+ repos[i].plainName = repos[i].name.substring(9);
11
+
12
+ if (directory) {
13
+ repos[i].absolutePath = path.resolve(directory, repos[i].path);
14
+ const parsedPath = path.parse(repos[i].absolutePath);
15
+ repos[i].directory = parsedPath.dir
16
+ }
17
+
18
+ let packagejson = path.resolve(repos[i].absolutePath, 'package.json');
19
+ if (!fs.existsSync(packagejson)) {
20
+ console.error('package json not found for', repos[i].name);
21
+ failed.push({
22
+ name: repos[i].name,
23
+ des: 'package json not found'
24
+ })
25
+ } else {
26
+
27
+ let packageObj
28
+ try {
29
+ packageObj = require(packagejson);
30
+ }
31
+ catch (err) {
32
+ console.error('packageObj', err.message)
33
+ }
34
+
35
+
36
+ repos[i].packageName = packageObj.name;
37
+
38
+ repos[i].deps = Object.keys(packageObj['dependencies'] || {})
39
+ .filter(packageName => packageName.startsWith('@cocreate/'));
40
+ repos[i].devDeps = Object.keys(packageObj['devDependencies'] || {})
41
+ .filter(packageName => packageName.startsWith('@cocreate/'));
42
+
43
+ if (!repos[i].packageManager) {
44
+ if (packageManager)
45
+ repos[i].packageManager = packageManager
46
+ else {
47
+ repos[i].packageManager = 'npm'
48
+ let lockFile = path.resolve(repos[i].absolutePath, 'package-lock.json');
49
+ if (!fs.existsSync(lockFile)) {
50
+ lockFile = path.resolve(repos[i].absolutePath, 'pnpm-lock.yaml');
51
+ if (fs.existsSync(lockFile))
52
+ repos[i].packageManager = 'pnpm'
53
+ else {
54
+ lockFile = path.resolve(repos[i].absolutePath, 'yarn.lock');
55
+ if (fs.existsSync(lockFile))
56
+ repos[i].packageManager = 'yarn'
57
+ else {
58
+ try {
59
+ const { error } = await exec('yarn --version');
60
+ if (!error)
61
+ repos[i].packageManager = 'yarn'
62
+ } catch(e) {
63
+
64
+ }
65
+ }
66
+ }
67
+ packageManager = repos[i].packageManager
68
+ }
69
+ }
70
+ }
71
+ }
72
+ }
73
+
74
+ return repos
75
75
  }
package/src/coc.js CHANGED
@@ -1,81 +1,81 @@
1
1
  #!/usr/bin/env node
2
- const path = require("path");
3
- const fs = require("fs");
4
- const execute = require('./execute');
5
- const argv = process.argv.slice(2);
6
- const addMeta = require('./addMeta');
7
-
8
-
9
- if (argv.length < 1) {
10
- console.error("enter some command to do something");
11
- process.exit(1);
12
- }
13
- let repos, command, config = {};
14
-
15
- const options = ['-self']
16
- for (let option of options) {
17
- if (argv.includes(option)) {
18
- config.self = true
19
- const index = argv.indexOf(option);
20
- delete argv[index];
21
- }
22
- }
23
-
24
- command = argv
25
- .map((part) => part.match(/ |'|"/) ? `'${part.replace(/'/, '\\\'')}'` : part)
26
- .join(" ");
27
-
28
- function getRepositories(path) {
29
- try {
30
- return require(path);
31
- }
32
- catch (err) {
33
- console.error('can not read repository file in'.red, path, 'error:'.red, err.message.red);
34
- process.exit(1);
35
- }
36
- }
37
-
38
- const currentRepoPath = path.resolve(process.cwd(), "./repositories.js");
39
- let packageJsonPath = path.resolve(process.cwd(), './package.json');
40
- let directory
41
-
42
- if (config['c'] && fs.existsSync(config['c'])) {
43
- repos = getRepositories(config['c']);
44
- directory = path.dirname(config['c']);
45
- console.warn(`using ${config['c']} configuration`.yellow);
46
- } else if (!config['self'] && fs.existsSync(currentRepoPath)) {
47
- repos = getRepositories(currentRepoPath);
48
- directory = path.dirname(currentRepoPath);
49
- console.warn(`using ${currentRepoPath} configuration`.yellow);
50
- } else if (fs.existsSync(packageJsonPath)) {
51
- let repoPath = path.resolve(process.cwd());
52
- let packageObj = require(packageJsonPath);
53
- let repoUrl = packageObj.repository.url.substring(12);
54
- repos = [{
55
- path: `${repoPath}`,
56
- repo: `${repoUrl}`
57
- }];
58
- directory = path.dirname(packageJsonPath);
59
- console.warn(`using ${packageJsonPath} configuration`.yellow);
60
- }
61
- // else {
62
- // console.error(`a configuration file can not be found`.red);
63
- // process.exit(1);
64
- // }
65
- config = { hideMessage: false, ...config };
66
-
67
- (async () => {
68
- if (repos && repos.length)
69
- repos = await addMeta(repos, [], directory)
70
- let failed = await execute(command, repos, config);
71
- if (failed) {
72
- if (failed.length === 0)
73
- process.exit(0);
74
- else {
75
- console.log(' **************** failures **************** '.red);
76
- for (let failure of failed)
77
- console.log(`${failure.name}: ${failure.des}`.red);
78
-
79
- }
80
- }
81
- })();
2
+ const path = require("path");
3
+ const fs = require("fs");
4
+ const execute = require('./execute');
5
+ const argv = process.argv.slice(2);
6
+ const addMeta = require('./addMeta');
7
+
8
+
9
+ if (argv.length < 1) {
10
+ console.error("enter some command to do something");
11
+ process.exit(1);
12
+ }
13
+ let repos, command, config = {};
14
+
15
+ const options = ['-self']
16
+ for (let option of options) {
17
+ if (argv.includes(option)) {
18
+ config.self = true
19
+ const index = argv.indexOf(option);
20
+ delete argv[index];
21
+ }
22
+ }
23
+
24
+ command = argv
25
+ .map((part) => part.match(/ |'|"/) ? `'${part.replace(/'/, '\\\'')}'` : part)
26
+ .join(" ");
27
+
28
+ function getRepositories(path) {
29
+ try {
30
+ return require(path);
31
+ }
32
+ catch (err) {
33
+ console.error('can not read repository file in'.red, path, 'error:'.red, err.message.red);
34
+ process.exit(1);
35
+ }
36
+ }
37
+
38
+ const currentRepoPath = path.resolve(process.cwd(), "./repositories.js");
39
+ let packageJsonPath = path.resolve(process.cwd(), './package.json');
40
+ let directory
41
+
42
+ if (config['c'] && fs.existsSync(config['c'])) {
43
+ repos = getRepositories(config['c']);
44
+ directory = path.dirname(config['c']);
45
+ console.warn(`using ${config['c']} configuration`.yellow);
46
+ } else if (!config['self'] && fs.existsSync(currentRepoPath)) {
47
+ repos = getRepositories(currentRepoPath);
48
+ directory = path.dirname(currentRepoPath);
49
+ console.warn(`using ${currentRepoPath} configuration`.yellow);
50
+ } else if (fs.existsSync(packageJsonPath)) {
51
+ let repoPath = path.resolve(process.cwd());
52
+ let packageObj = require(packageJsonPath);
53
+ let repoUrl = packageObj.repository.url.substring(12);
54
+ repos = [{
55
+ path: `${repoPath}`,
56
+ repo: `${repoUrl}`
57
+ }];
58
+ directory = path.dirname(packageJsonPath);
59
+ console.warn(`using ${packageJsonPath} configuration`.yellow);
60
+ }
61
+ // else {
62
+ // console.error(`a configuration file can not be found`.red);
63
+ // process.exit(1);
64
+ // }
65
+ config = { hideMessage: false, ...config };
66
+
67
+ (async () => {
68
+ if (repos && repos.length)
69
+ repos = await addMeta(repos, [], directory)
70
+ let failed = await execute(command, repos, config);
71
+ if (failed) {
72
+ if (failed.length === 0)
73
+ process.exit(0);
74
+ else {
75
+ console.log(' **************** failures **************** '.red);
76
+ for (let failure of failed)
77
+ console.log(`${failure.name}: ${failure.des}`.red);
78
+
79
+ }
80
+ }
81
+ })();
@@ -1,85 +1,85 @@
1
- let fs = require('fs');
2
- const path = require("path")
3
- const colors = require('colors');
4
- const util = require('node:util');
5
- const exec = util.promisify(require('node:child_process').exec);
6
-
7
-
8
- let pathList, nameList, item = {}, failed = [];
9
-
10
- module.exports = async function bump(repos, args) {
11
- pathList = repos.map(o => o.absolutePath)
12
- if (repos.length === 1) {
13
- let packageJsonPath = path.resolve(process.cwd(), './package.json');
14
-
15
- if (fs.existsSync(packageJsonPath)) {
16
- let object = require(packageJsonPath)
17
- if (object.dependencies) {
18
- for (let key of Object.keys(object.dependencies)) {
19
- if (key.startsWith("@cocreate/")) {
20
- const version = await exec(`npm view ${key} version`);
21
- item[key] = `^${version.stdout}`.trim()
22
- }
23
- }
24
- console.log('bump versions', item)
25
-
26
- for (let name of Object.keys(item)) {
27
- bumpVersion(packageJsonPath, name)
28
- }
29
- }
30
- }
31
-
32
- } else {
33
- nameList = pathList.map(fn => path.basename(fn).toLowerCase());
34
-
35
- for (let [index, name] of nameList.entries()) {
36
- getVersions(pathList[index] + '/package.json', `@${name}`)
37
- }
38
-
39
- console.log('bump versions', item)
40
-
41
- for (let [index, name] of nameList.entries()) {
42
- bumpVersion(pathList[index] + '/package.json', name)
43
- }
44
-
45
- }
46
-
47
- console.log('completed')
48
- return failed;
49
- }
50
-
51
- function getVersions(filePath) {
52
- if (fs.existsSync(filePath)) {
53
- let object = require(filePath)
54
- if (object.name && object.version) {
55
- item[object.name] = `^${object.version}`
56
- }
57
- } else {
58
- failed.push({name: 'get version', des: 'path doesn\'t exist:' + filePath})
59
- }
60
- }
61
-
62
- function bumpVersion(filePath, name) {
63
- let object = require(filePath)
64
- if (object) {
65
- let newObject = {...object}
66
-
67
- if (!object.dependencies)
68
- return console.log(name, 'not updated')
69
- else {
70
- for (const name of Object.keys(object.dependencies)) {
71
- if (item[name]) {
72
- newObject.dependencies[name] = item[name]
73
- }
74
- }
75
-
76
- if (fs.existsSync(filePath)){
77
- fs.unlinkSync(filePath)
78
- }
79
-
80
- fs.writeFileSync(filePath, JSON.stringify(object, null, 2))
81
- }
82
- } else {
83
- failed.push({name: 'bump version', des: 'path doesn\'t exist:' + filePath})
84
- }
85
- }
1
+ let fs = require('fs');
2
+ const path = require("path")
3
+ const colors = require('colors');
4
+ const util = require('node:util');
5
+ const exec = util.promisify(require('node:child_process').exec);
6
+
7
+
8
+ let pathList, nameList, item = {}, failed = [];
9
+
10
+ module.exports = async function bump(repos, args) {
11
+ pathList = repos.map(o => o.absolutePath)
12
+ if (repos.length === 1) {
13
+ let packageJsonPath = path.resolve(process.cwd(), './package.json');
14
+
15
+ if (fs.existsSync(packageJsonPath)) {
16
+ let object = require(packageJsonPath)
17
+ if (object.dependencies) {
18
+ for (let key of Object.keys(object.dependencies)) {
19
+ if (key.startsWith("@cocreate/")) {
20
+ const version = await exec(`npm view ${key} version`);
21
+ item[key] = `^${version.stdout}`.trim()
22
+ }
23
+ }
24
+ console.log('bump versions', item)
25
+
26
+ for (let name of Object.keys(item)) {
27
+ bumpVersion(packageJsonPath, name)
28
+ }
29
+ }
30
+ }
31
+
32
+ } else {
33
+ nameList = pathList.map(fn => path.basename(fn).toLowerCase());
34
+
35
+ for (let [index, name] of nameList.entries()) {
36
+ getVersions(pathList[index] + '/package.json', `@${name}`)
37
+ }
38
+
39
+ console.log('bump versions', item)
40
+
41
+ for (let [index, name] of nameList.entries()) {
42
+ bumpVersion(pathList[index] + '/package.json', name)
43
+ }
44
+
45
+ }
46
+
47
+ console.log('completed')
48
+ return failed;
49
+ }
50
+
51
+ function getVersions(filePath) {
52
+ if (fs.existsSync(filePath)) {
53
+ let object = require(filePath)
54
+ if (object.name && object.version) {
55
+ item[object.name] = `^${object.version}`
56
+ }
57
+ } else {
58
+ failed.push({name: 'get version', des: 'path doesn\'t exist:' + filePath})
59
+ }
60
+ }
61
+
62
+ function bumpVersion(filePath, name) {
63
+ let object = require(filePath)
64
+ if (object) {
65
+ let newObject = {...object}
66
+
67
+ if (!object.dependencies)
68
+ return console.log(name, 'not updated')
69
+ else {
70
+ for (const name of Object.keys(object.dependencies)) {
71
+ if (item[name]) {
72
+ newObject.dependencies[name] = item[name]
73
+ }
74
+ }
75
+
76
+ if (fs.existsSync(filePath)){
77
+ fs.unlinkSync(filePath)
78
+ }
79
+
80
+ fs.writeFileSync(filePath, JSON.stringify(object, null, 2))
81
+ }
82
+ } else {
83
+ failed.push({name: 'bump version', des: 'path doesn\'t exist:' + filePath})
84
+ }
85
+ }
@@ -11,12 +11,12 @@ module.exports = async function gitClone(repos, args) {
11
11
  if (cwdPath !== repos[i].absolutePath) {
12
12
  if (!fs.existsSync(repos[i].directory))
13
13
  fs.mkdirSync(repos[i].directory);
14
-
14
+
15
15
  let exitCode = await spawn('git', ['clone', `https://${repos[i].repo}`], { stdio: 'inherit', cwd: repos[i].directory })
16
16
  if (exitCode !== 0) {
17
17
  failed.push({ name: repos[i].name, des: `cloning failed` })
18
18
  }
19
-
19
+
20
20
  }
21
21
  }
22
22