@cocreate/cli 1.32.1 → 1.33.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/CHANGELOG.md +15 -0
- package/CoCreate.config.js +1 -1
- package/package.json +2 -2
- package/src/commands/bump.js +22 -16
- package/src/commands/config.js +15 -8
- package/src/commands/fs/config.js +2 -2
- package/src/commands/symlink.js +32 -0
package/CHANGELOG.md
CHANGED
|
@@ -1,3 +1,18 @@
|
|
|
1
|
+
# [1.33.0](https://github.com/CoCreate-app/CoCreate-cli/compare/v1.32.2...v1.33.0) (2023-06-11)
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
### Features
|
|
5
|
+
|
|
6
|
+
* bump.js will iterate through both dependencies and devDependencies ([b537963](https://github.com/CoCreate-app/CoCreate-cli/commit/b537963fb11b6e5f8c505b02f609d6879f87ecb7))
|
|
7
|
+
|
|
8
|
+
## [1.32.2](https://github.com/CoCreate-app/CoCreate-cli/compare/v1.32.1...v1.32.2) (2023-06-11)
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
### Bug Fixes
|
|
12
|
+
|
|
13
|
+
* renamed db to storage ([fa41daf](https://github.com/CoCreate-app/CoCreate-cli/commit/fa41daf2344f2c8768bfd2db10c58ce4bad403be))
|
|
14
|
+
* renamed hosts to host. the value can be a string or an array of strings ([932f60b](https://github.com/CoCreate-app/CoCreate-cli/commit/932f60bdd7890da296b9d4d5ea92c9c7aeb9398c))
|
|
15
|
+
|
|
1
16
|
## [1.32.1](https://github.com/CoCreate-app/CoCreate-cli/compare/v1.32.0...v1.32.1) (2023-06-10)
|
|
2
17
|
|
|
3
18
|
|
package/CoCreate.config.js
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@cocreate/cli",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.33.0",
|
|
4
4
|
"description": "Polyrepo management bash CLI tool. Run all git commands and yarn commands on multiple repositories. Also includes a few custom macros for cloning, installing, etc.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"cli",
|
|
@@ -60,7 +60,7 @@
|
|
|
60
60
|
"@cocreate/cli": "^1.29.3"
|
|
61
61
|
},
|
|
62
62
|
"dependencies": {
|
|
63
|
-
"@cocreate/file": "^1.2.
|
|
63
|
+
"@cocreate/file": "^1.2.5",
|
|
64
64
|
"glob": "^7.1.7",
|
|
65
65
|
"prettier": "^2.3.2"
|
|
66
66
|
}
|
package/src/commands/bump.js
CHANGED
|
@@ -8,13 +8,16 @@ let pathList, nameList, item = {}, failed = [];
|
|
|
8
8
|
|
|
9
9
|
module.exports = async function bump(repos, args) {
|
|
10
10
|
pathList = repos.map(o => o.absolutePath)
|
|
11
|
-
if (repos.length
|
|
11
|
+
if (repos.length <= 1) {
|
|
12
12
|
let packageJsonPath = path.resolve(process.cwd(), './package.json');
|
|
13
13
|
|
|
14
14
|
if (fs.existsSync(packageJsonPath)) {
|
|
15
|
-
let
|
|
16
|
-
if (
|
|
17
|
-
|
|
15
|
+
let json = require(packageJsonPath)
|
|
16
|
+
if (json) {
|
|
17
|
+
let dependencies = json.dependencies || {}
|
|
18
|
+
let devDependencies = json.devDependencies || {}
|
|
19
|
+
let object = { ...dependencies, ...devDependencies }
|
|
20
|
+
for (let key of Object.keys(object)) {
|
|
18
21
|
if (key.startsWith("@cocreate/")) {
|
|
19
22
|
const version = await exec(`npm view ${key} version`);
|
|
20
23
|
item[key] = `^${version.stdout}`.trim()
|
|
@@ -30,7 +33,7 @@ module.exports = async function bump(repos, args) {
|
|
|
30
33
|
|
|
31
34
|
} else {
|
|
32
35
|
nameList = pathList.map(fn => path.basename(fn).toLowerCase());
|
|
33
|
-
|
|
36
|
+
console.log('namelist', nameList)
|
|
34
37
|
for (let [index, name] of nameList.entries()) {
|
|
35
38
|
getVersions(pathList[index] + '/package.json', `@${name}`)
|
|
36
39
|
}
|
|
@@ -62,22 +65,25 @@ function bumpVersion(filePath, name) {
|
|
|
62
65
|
let object = require(filePath)
|
|
63
66
|
if (object) {
|
|
64
67
|
let newObject = { ...object }
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
if (item[name]) {
|
|
71
|
-
newObject.dependencies[name] = item[name]
|
|
72
|
-
}
|
|
68
|
+
let dependencies = object.dependencies || {}
|
|
69
|
+
let devDependencies = object.devDependencies || {}
|
|
70
|
+
for (const name of Object.keys(dependencies)) {
|
|
71
|
+
if (item[name]) {
|
|
72
|
+
newObject.dependencies[name] = item[name]
|
|
73
73
|
}
|
|
74
|
+
}
|
|
74
75
|
|
|
75
|
-
|
|
76
|
-
|
|
76
|
+
for (const name of Object.keys(devDependencies)) {
|
|
77
|
+
if (item[name]) {
|
|
78
|
+
newObject.devDependencies[name] = item[name]
|
|
77
79
|
}
|
|
80
|
+
}
|
|
78
81
|
|
|
79
|
-
|
|
82
|
+
if (fs.existsSync(filePath)) {
|
|
83
|
+
fs.unlinkSync(filePath)
|
|
80
84
|
}
|
|
85
|
+
|
|
86
|
+
fs.writeFileSync(filePath, JSON.stringify(object, null, 2))
|
|
81
87
|
} else {
|
|
82
88
|
failed.push({ name: 'bump version', des: 'path doesn\'t exist:' + filePath })
|
|
83
89
|
}
|
package/src/commands/config.js
CHANGED
|
@@ -71,14 +71,21 @@ module.exports = async function CoCreateConfig(items, processEnv = true, updateG
|
|
|
71
71
|
|
|
72
72
|
if (process.env[key]) {
|
|
73
73
|
config[key] = process.env[key];
|
|
74
|
-
} else
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
74
|
+
} else {
|
|
75
|
+
if (localConfig[key]) {
|
|
76
|
+
config[key] = localConfig[key];
|
|
77
|
+
} else if (globalConfig[key]) {
|
|
78
|
+
config[key] = globalConfig[key];
|
|
79
|
+
} else if (prompt || prompt === '') {
|
|
80
|
+
config[key] = await promptForInput(prompt || `${key}: `);
|
|
81
|
+
if (updateGlobal) update = true;
|
|
82
|
+
}
|
|
83
|
+
if (processEnv) {
|
|
84
|
+
if (typeof config[key] === 'object')
|
|
85
|
+
process.env[key] = JSON.stringify(config[key]);
|
|
86
|
+
else
|
|
87
|
+
process.env[key] = config[key];
|
|
88
|
+
}
|
|
82
89
|
}
|
|
83
90
|
}
|
|
84
91
|
}
|
|
@@ -39,7 +39,7 @@ function update(MdPath) {
|
|
|
39
39
|
"name": "index.html",
|
|
40
40
|
"path": "/docs/${name}/index.html",
|
|
41
41
|
"src": "{{./docs/index.html}}",
|
|
42
|
-
"
|
|
42
|
+
"host": [
|
|
43
43
|
"general.cocreate.app"
|
|
44
44
|
],
|
|
45
45
|
"directory": "/docs/${name}",
|
|
@@ -56,7 +56,7 @@ function update(MdPath) {
|
|
|
56
56
|
|
|
57
57
|
if (!document_id.length)
|
|
58
58
|
console.log("Document_id Undefined: ", MdPath);
|
|
59
|
-
if (document_id.length != 24 && document_id.length != 0
|
|
59
|
+
if (document_id.length != 24 && document_id.length != 0)
|
|
60
60
|
console.log("Document_id not valid! please check your config: ", MdPath);
|
|
61
61
|
else {
|
|
62
62
|
console.log(MdPath, " -> document_id : ", document_id);
|
package/src/commands/symlink.js
CHANGED
|
@@ -40,6 +40,18 @@ async function createSymlink(repo) {
|
|
|
40
40
|
let dest = path.resolve(dpath, 'node_modules');
|
|
41
41
|
if (dest) {
|
|
42
42
|
if (fs.existsSync(dest)) {
|
|
43
|
+
|
|
44
|
+
if (!cwdNodeModulesPath.includes('/CoCreateJS')) {
|
|
45
|
+
let isSymlink = await isSymlinkDirectory(dest)
|
|
46
|
+
if (isSymlink) {
|
|
47
|
+
const targetPath = await getSymlinkTargetPath(dest);
|
|
48
|
+
if (targetPath.includes('/CoCreateJS')) {
|
|
49
|
+
console.warn('symlink already exists with CoCreateJS')
|
|
50
|
+
return
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
|
|
43
55
|
fs.rm(dest, { recursive: true, force: true }, function (err) {
|
|
44
56
|
if (err) {
|
|
45
57
|
failed.push({ name: 'symlink', des: 'with response:' + response, err })
|
|
@@ -111,3 +123,23 @@ async function install(repo, repos) {
|
|
|
111
123
|
}
|
|
112
124
|
|
|
113
125
|
}
|
|
126
|
+
|
|
127
|
+
async function isSymlinkDirectory(path) {
|
|
128
|
+
try {
|
|
129
|
+
const stats = await fs.promises.lstat(path);
|
|
130
|
+
return stats.isSymbolicLink();
|
|
131
|
+
} catch (err) {
|
|
132
|
+
throw err;
|
|
133
|
+
}
|
|
134
|
+
}
|
|
135
|
+
|
|
136
|
+
async function getSymlinkTargetPath(symlinkPath) {
|
|
137
|
+
try {
|
|
138
|
+
const target = await fs.promises.readlink(symlinkPath);
|
|
139
|
+
const targetPath = fs.realpathSync(target);
|
|
140
|
+
return targetPath;
|
|
141
|
+
} catch (err) {
|
|
142
|
+
throw err;
|
|
143
|
+
}
|
|
144
|
+
}
|
|
145
|
+
|