@cocreate/cli 1.49.0 → 1.51.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 +29 -0
- package/CoCreate.config.js +498 -413
- package/docs/index.html +250 -250
- package/package.json +5 -5
- package/prettier.config.js +2 -0
- package/src/addMeta.js +74 -67
- package/src/coc.js +166 -114
- package/src/commands/acme.js +19 -22
- package/src/commands/bump.js +149 -87
- package/src/commands/clone.js +26 -22
- package/src/commands/fs/automated.js +1 -1
- package/src/commands/fs/config.js +1 -1
- package/src/commands/fs/gitignore.js +13 -22
- package/src/commands/fs/manual.js +17 -27
- package/src/commands/fs/prettier.config.js +1 -1
- package/src/commands/fs/remove.js +7 -12
- package/src/commands/fs/replace.js +23 -31
- package/src/commands/fs/webpack.js +143 -149
- package/src/commands/install.js +18 -22
- package/src/commands/link.js +73 -60
- package/src/commands/nginx.js +19 -22
- package/src/commands/symlink.js +132 -115
- package/src/execute.js +63 -50
- package/src/index.js +3 -0
- package/src/spinner.js +85 -0
package/src/commands/bump.js
CHANGED
|
@@ -1,92 +1,154 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
const
|
|
4
|
-
const
|
|
5
|
-
const
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
console.log('completed')
|
|
49
|
-
return failed;
|
|
50
|
-
}
|
|
1
|
+
// Import necessary modules
|
|
2
|
+
let fs = require("fs"); // File system module
|
|
3
|
+
const path = require("path"); // Path module for handling file paths
|
|
4
|
+
const util = require("node:util"); // Utility module for different helper functions
|
|
5
|
+
const exec = util.promisify(require("node:child_process").exec); // Promisified version of exec
|
|
6
|
+
const createSpinner = require("../spinner"); // Import custom spinner module
|
|
7
|
+
|
|
8
|
+
// Initialize variables to use throughout the module update process
|
|
9
|
+
let pathList = [], // Array to store paths to package.json files
|
|
10
|
+
item = {}, // Object to store the latest versions of modules
|
|
11
|
+
failed = []; // Array to track any failures that occur
|
|
12
|
+
|
|
13
|
+
let promiseMap = new Map(); // A map to cache promises for fetching versions
|
|
14
|
+
|
|
15
|
+
/**
|
|
16
|
+
* Updates module versions across multiple repositories.
|
|
17
|
+
* @param {Array} repos - An array of repository objects containing `absolutePath`.
|
|
18
|
+
* @param {Object} args - Additional arguments for the update process (not used here but passed for potential future use).
|
|
19
|
+
* @returns {Promise<Array>} - Resolves with the list of failed update attempts.
|
|
20
|
+
*/
|
|
21
|
+
module.exports = async function update(repos, args) {
|
|
22
|
+
pathList = repos.map((o) => path.resolve(o.absolutePath, "package.json"));
|
|
23
|
+
|
|
24
|
+
// Start a spinner to indicate progress
|
|
25
|
+
const spinner = createSpinner({
|
|
26
|
+
prefix: "Waiting for all versions to be fetched"
|
|
27
|
+
});
|
|
28
|
+
|
|
29
|
+
// Trigger version fetching for each package.json path
|
|
30
|
+
for (let filePath of pathList) {
|
|
31
|
+
getVersions(filePath);
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
// Await the resolution of all version fetching promises
|
|
35
|
+
await Promise.all(promiseMap.values());
|
|
36
|
+
|
|
37
|
+
// Populate the 'item' object with fetched versions
|
|
38
|
+
for (let [key, promise] of promiseMap) {
|
|
39
|
+
const version = await promise;
|
|
40
|
+
if (version) {
|
|
41
|
+
item[key] = `^${version}`;
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
// End spinner as fetching process is complete
|
|
46
|
+
spinner.end();
|
|
51
47
|
|
|
48
|
+
// Update each package.json with new version data
|
|
49
|
+
for (let filePath of pathList) {
|
|
50
|
+
updateVersion(filePath);
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
console.log("Completed updating modules to their latest versions.");
|
|
54
|
+
return failed;
|
|
55
|
+
};
|
|
56
|
+
|
|
57
|
+
/**
|
|
58
|
+
* Fetches the latest versions of dependencies listed in a package.json file.
|
|
59
|
+
* @param {string} filePath - The path to the package.json file.
|
|
60
|
+
*/
|
|
52
61
|
function getVersions(filePath) {
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
62
|
+
if (fs.existsSync(filePath)) {
|
|
63
|
+
let object = require(filePath); // Load JSON content
|
|
64
|
+
const dependencies = object.dependencies || {}; // Current dependencies
|
|
65
|
+
const devDependencies = object.devDependencies || {}; // Current devDependencies
|
|
66
|
+
const allDependencies = { ...dependencies, ...devDependencies }; // Combine both
|
|
67
|
+
|
|
68
|
+
// Iterate over each dependency
|
|
69
|
+
for (const key of Object.keys(allDependencies)) {
|
|
70
|
+
// Check and process only @cocreate/ prefixed packages
|
|
71
|
+
if (key.startsWith("@cocreate/") && !promiseMap.has(key)) {
|
|
72
|
+
const promise = exec(`npm view ${key} version`)
|
|
73
|
+
.then((versionObj) => versionObj.stdout.trim())
|
|
74
|
+
.catch((error) => {
|
|
75
|
+
failed.push({ name: key, error: error.message });
|
|
76
|
+
console.error(
|
|
77
|
+
`Failed fetching version for ${key}: ${error.message}`
|
|
78
|
+
);
|
|
79
|
+
return null;
|
|
80
|
+
});
|
|
81
|
+
promiseMap.set(key, promise);
|
|
82
|
+
}
|
|
83
|
+
}
|
|
84
|
+
} else {
|
|
85
|
+
const errorMessage = `Path doesn't exist: ${filePath}`;
|
|
86
|
+
failed.push({
|
|
87
|
+
name: "get version",
|
|
88
|
+
error: errorMessage
|
|
89
|
+
});
|
|
90
|
+
console.error(errorMessage);
|
|
91
|
+
}
|
|
61
92
|
}
|
|
62
93
|
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
94
|
+
/**
|
|
95
|
+
* Updates the package.json file with the latest module versions.
|
|
96
|
+
* @param {string} filePath - The path to the package.json file.
|
|
97
|
+
*/
|
|
98
|
+
function updateVersion(filePath) {
|
|
99
|
+
if (fs.existsSync(filePath)) {
|
|
100
|
+
delete require.cache[require.resolve(filePath)];
|
|
101
|
+
const object = require(filePath);
|
|
102
|
+
|
|
103
|
+
if (object) {
|
|
104
|
+
const dependencies = object.dependencies || {};
|
|
105
|
+
const devDependencies = object.devDependencies || {};
|
|
106
|
+
const allDependencies = { ...dependencies, ...devDependencies };
|
|
107
|
+
|
|
108
|
+
let updated = false;
|
|
109
|
+
let newObject = { ...object };
|
|
110
|
+
|
|
111
|
+
for (let key of Object.keys(allDependencies)) {
|
|
112
|
+
if (!key.startsWith("@cocreate/")) continue;
|
|
113
|
+
const currentVersion = allDependencies[key];
|
|
114
|
+
const latestVersion = item[key];
|
|
115
|
+
|
|
116
|
+
if (latestVersion && latestVersion !== currentVersion) {
|
|
117
|
+
if (dependencies[key]) {
|
|
118
|
+
newObject.dependencies[key] = latestVersion;
|
|
119
|
+
}
|
|
120
|
+
if (devDependencies[key]) {
|
|
121
|
+
newObject.devDependencies[key] = latestVersion;
|
|
122
|
+
}
|
|
123
|
+
|
|
124
|
+
updated = true;
|
|
125
|
+
console.log(
|
|
126
|
+
`Updated ${key} from ${currentVersion} to ${latestVersion}.`
|
|
127
|
+
);
|
|
128
|
+
} else {
|
|
129
|
+
if (latestVersion === null) {
|
|
130
|
+
console.log(
|
|
131
|
+
`Could not update ${key}: Failed to fetch the latest version.`
|
|
132
|
+
);
|
|
133
|
+
} else {
|
|
134
|
+
console.log(
|
|
135
|
+
`Skipped updating ${key}, already at the latest version: ${currentVersion}.`
|
|
136
|
+
);
|
|
137
|
+
}
|
|
138
|
+
}
|
|
139
|
+
}
|
|
140
|
+
|
|
141
|
+
if (updated) {
|
|
142
|
+
fs.writeFileSync(filePath, JSON.stringify(newObject, null, 2));
|
|
143
|
+
console.log(`Updated ${filePath} successfully.`);
|
|
144
|
+
}
|
|
145
|
+
}
|
|
146
|
+
} else {
|
|
147
|
+
const errorMessage = `Path doesn't exist: ${filePath}`;
|
|
148
|
+
failed.push({
|
|
149
|
+
name: "update version",
|
|
150
|
+
error: errorMessage
|
|
151
|
+
});
|
|
152
|
+
console.error(errorMessage);
|
|
153
|
+
}
|
|
92
154
|
}
|
package/src/commands/clone.js
CHANGED
|
@@ -1,28 +1,32 @@
|
|
|
1
|
-
const spawn = require(
|
|
2
|
-
const path = require(
|
|
3
|
-
let fs = require(
|
|
1
|
+
const spawn = require("../spawn");
|
|
2
|
+
const path = require("path");
|
|
3
|
+
let fs = require("fs");
|
|
4
4
|
|
|
5
5
|
module.exports = async function gitClone(repos, args) {
|
|
6
|
-
|
|
7
|
-
|
|
6
|
+
const failed = [];
|
|
7
|
+
const cwdPath = path.resolve(process.cwd());
|
|
8
8
|
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
9
|
+
for (let i = 0; i < repos.length; i++) {
|
|
10
|
+
// TODO: Check if path exist and if git.config or package.json exist continue
|
|
11
|
+
if (cwdPath !== repos[i].absolutePath) {
|
|
12
|
+
if (!fs.existsSync(repos[i].directory))
|
|
13
|
+
fs.mkdirSync(repos[i].directory);
|
|
14
14
|
|
|
15
|
-
|
|
16
|
-
|
|
15
|
+
if (
|
|
16
|
+
!repos[i].repo.startsWith("http://") &&
|
|
17
|
+
!repos[i].repo.startsWith("https://")
|
|
18
|
+
)
|
|
19
|
+
repos[i].repo = "https://" + repos[i].repo;
|
|
17
20
|
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
21
|
+
let exitCode = await spawn("git", ["clone", `${repos[i].repo}`], {
|
|
22
|
+
stdio: "inherit",
|
|
23
|
+
cwd: repos[i].directory
|
|
24
|
+
});
|
|
25
|
+
if (exitCode !== 0) {
|
|
26
|
+
failed.push({ name: repos[i].name, error: `cloning failed` });
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
}
|
|
22
30
|
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
return failed;
|
|
27
|
-
|
|
28
|
-
}
|
|
31
|
+
return failed;
|
|
32
|
+
};
|
|
@@ -137,7 +137,7 @@ jobs:
|
|
|
137
137
|
|
|
138
138
|
// Define the directories with wildcards
|
|
139
139
|
const directories = [
|
|
140
|
-
"../../../../../CoCreate-
|
|
140
|
+
"../../../../../CoCreate-modules/*/",
|
|
141
141
|
"../../../../../CoCreate-apps/*/",
|
|
142
142
|
"../../../../../CoCreate-plugins/*/",
|
|
143
143
|
"../../../../../CoCreateCSS/",
|
|
@@ -111,7 +111,7 @@ function createOrUpdateFile(directoryPath, fileName) {
|
|
|
111
111
|
|
|
112
112
|
// Define the directories with wildcards
|
|
113
113
|
const directories = [
|
|
114
|
-
"../../../../../CoCreate-
|
|
114
|
+
"../../../../../CoCreate-modules/*/",
|
|
115
115
|
"../../../../../CoCreate-apps/*/",
|
|
116
116
|
"../../../../../CoCreate-plugins/*/",
|
|
117
117
|
"../../../../../CoCreateCSS/",
|
|
@@ -1,41 +1,32 @@
|
|
|
1
1
|
let glob = require("glob");
|
|
2
|
-
let fs = require(
|
|
3
|
-
const path = require("path")
|
|
2
|
+
let fs = require("fs");
|
|
3
|
+
const path = require("path");
|
|
4
4
|
|
|
5
5
|
function globUpdater(er, files) {
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
else
|
|
9
|
-
files.forEach(filename => update(filename))
|
|
6
|
+
if (er) console.log(files, "glob resolving issue");
|
|
7
|
+
else files.forEach((filename) => update(filename));
|
|
10
8
|
}
|
|
11
9
|
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
10
|
function update(Path) {
|
|
16
|
-
|
|
11
|
+
let fileContent = `# ignore
|
|
17
12
|
node_modules
|
|
18
13
|
dist
|
|
19
14
|
.npmrc
|
|
20
15
|
|
|
21
16
|
`;
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
fs.writeFileSync(Path, fileContent)
|
|
25
|
-
|
|
17
|
+
if (fs.existsSync(Path)) fs.unlinkSync(Path);
|
|
18
|
+
fs.writeFileSync(Path, fileContent);
|
|
26
19
|
}
|
|
27
20
|
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
// glob("../CoCreate-components/CoCreate-action/.gitignore", globUpdater)
|
|
21
|
+
// glob("../CoCreate-modules/CoCreate-action/.gitignore", globUpdater)
|
|
31
22
|
// glob("./.gitignore", globUpdater)
|
|
32
23
|
// glob("../CoCreate-adminUI/.gitignore", globUpdater)
|
|
33
|
-
glob("../CoCreate-
|
|
34
|
-
glob("../CoCreate-apps/*/.gitignore", globUpdater)
|
|
35
|
-
glob("../CoCreate-plugins/*/.gitignore", globUpdater)
|
|
24
|
+
glob("../CoCreate-modules/*/.gitignore", globUpdater);
|
|
25
|
+
glob("../CoCreate-apps/*/.gitignore", globUpdater);
|
|
26
|
+
glob("../CoCreate-plugins/*/.gitignore", globUpdater);
|
|
36
27
|
// glob("../CoCreate-website/.gitignore", globUpdater)
|
|
37
28
|
// glob("../CoCreate-website-template/.gitignore", globUpdater)
|
|
38
|
-
glob("../CoCreateCSS/.gitignore", globUpdater)
|
|
29
|
+
glob("../CoCreateCSS/.gitignore", globUpdater);
|
|
39
30
|
// glob("../CoCreateJS/.gitignore", globUpdater)
|
|
40
31
|
|
|
41
|
-
console.log(
|
|
32
|
+
console.log("finished");
|
|
@@ -1,26 +1,21 @@
|
|
|
1
1
|
let glob = require("glob");
|
|
2
|
-
let fs = require(
|
|
3
|
-
const path = require("path")
|
|
2
|
+
let fs = require("fs");
|
|
3
|
+
const path = require("path");
|
|
4
4
|
|
|
5
5
|
function globUpdater(er, files) {
|
|
6
|
-
|
|
7
|
-
if (er)
|
|
8
|
-
console.log(files, 'glob resolving issue')
|
|
6
|
+
if (er) console.log(files, "glob resolving issue");
|
|
9
7
|
else
|
|
10
|
-
files.forEach(filename => {
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
})
|
|
15
|
-
|
|
8
|
+
files.forEach((filename) => {
|
|
9
|
+
console.log(filename + "/manual.yml", "glob resolving issue");
|
|
10
|
+
update(filename + "/manual.yml");
|
|
11
|
+
});
|
|
16
12
|
}
|
|
17
13
|
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
14
|
function update(Path) {
|
|
22
15
|
// component name
|
|
23
|
-
let name = path
|
|
16
|
+
let name = path
|
|
17
|
+
.basename(path.resolve(path.dirname(Path), "../.."))
|
|
18
|
+
.substring(9);
|
|
24
19
|
let fileContent = `name: Manual Workflow
|
|
25
20
|
on:
|
|
26
21
|
workflow_dispatch:
|
|
@@ -68,19 +63,14 @@ jobs:
|
|
|
68
63
|
|
|
69
64
|
`;
|
|
70
65
|
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
fs.unlinkSync(Path)
|
|
74
|
-
fs.writeFileSync(Path, fileContent)
|
|
75
|
-
|
|
66
|
+
if (fs.existsSync(Path)) fs.unlinkSync(Path);
|
|
67
|
+
fs.writeFileSync(Path, fileContent);
|
|
76
68
|
}
|
|
77
69
|
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
glob("../CoCreate-
|
|
82
|
-
glob("../CoCreate-apps/*/.github/workflows/", globUpdater)
|
|
83
|
-
glob("../CoCreate-plugins/*/.github/workflows/", globUpdater)
|
|
70
|
+
// glob("../CoCreate-modules/CoCreate-action/.github/workflows", globUpdater)
|
|
71
|
+
glob("../CoCreate-modules/*/.github/workflows/", globUpdater);
|
|
72
|
+
glob("../CoCreate-apps/*/.github/workflows/", globUpdater);
|
|
73
|
+
glob("../CoCreate-plugins/*/.github/workflows/", globUpdater);
|
|
84
74
|
|
|
85
75
|
// substrin (9) removes CoCreateC leving namme as SS
|
|
86
76
|
// glob("../CoCreateCSS/.github/workflows/", globUpdater)
|
|
@@ -88,4 +78,4 @@ glob("../CoCreate-plugins/*/.github/workflows/", globUpdater)
|
|
|
88
78
|
// does not need to add name... will require for name to be removed from destination
|
|
89
79
|
// glob("../CoCreateJS/.github/workflows/", globUpdater)
|
|
90
80
|
|
|
91
|
-
console.log(
|
|
81
|
+
console.log("finished");
|
|
@@ -77,7 +77,7 @@ function createOrUpdateFile(directoryPath, fileName) {
|
|
|
77
77
|
|
|
78
78
|
// Define the directories with wildcards
|
|
79
79
|
const directories = [
|
|
80
|
-
"../../../../../CoCreate-
|
|
80
|
+
"../../../../../CoCreate-modules/*/",
|
|
81
81
|
"../../../../../CoCreate-apps/*/",
|
|
82
82
|
"../../../../../CoCreate-plugins/*/",
|
|
83
83
|
"../../../../../CoCreateCSS/",
|
|
@@ -1,22 +1,17 @@
|
|
|
1
1
|
let glob = require("glob");
|
|
2
|
-
let fs = require(
|
|
2
|
+
let fs = require("fs");
|
|
3
3
|
|
|
4
4
|
function globUpdater(er, files) {
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
else
|
|
8
|
-
files.forEach(filename => update(filename))
|
|
5
|
+
if (er) console.log(files, "glob resolving issue");
|
|
6
|
+
else files.forEach((filename) => update(filename));
|
|
9
7
|
}
|
|
10
8
|
|
|
11
|
-
|
|
12
9
|
function update(YmlPath) {
|
|
13
|
-
|
|
14
|
-
fs.unlinkSync(YmlPath)
|
|
10
|
+
if (fs.existsSync(YmlPath)) fs.unlinkSync(YmlPath);
|
|
15
11
|
}
|
|
16
12
|
|
|
17
|
-
|
|
18
|
-
glob("../CoCreate-
|
|
19
|
-
// glob("../CoCreate-components/*/.github/workflows/automation.yml", globUpdater)
|
|
13
|
+
glob("../CoCreate-modules/CoCreate-action/dist", globUpdater);
|
|
14
|
+
// glob("../CoCreate-modules/*/.github/workflows/automation.yml", globUpdater)
|
|
20
15
|
// glob("../CoCreate-apps/*/.github/workflows/automation.yml", globUpdater)
|
|
21
16
|
// glob("../CoCreate-plugins/*/.github/workflows/automation.yml", globUpdater)
|
|
22
17
|
|
|
@@ -26,4 +21,4 @@ glob("../CoCreate-components/CoCreate-action/dist", globUpdater)
|
|
|
26
21
|
// does not need to add name... will require for name to be removed from destination
|
|
27
22
|
// glob("../CoCreateJS/.github/workflows/automation.yml", globUpdater)
|
|
28
23
|
|
|
29
|
-
console.log(
|
|
24
|
+
console.log("finished");
|
|
@@ -1,43 +1,35 @@
|
|
|
1
1
|
let glob = require("glob");
|
|
2
|
-
let fs = require(
|
|
3
|
-
const path = require("path")
|
|
2
|
+
let fs = require("fs");
|
|
3
|
+
const path = require("path");
|
|
4
4
|
|
|
5
5
|
function globUpdater(er, files) {
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
else
|
|
9
|
-
files.forEach(filename => update(filename))
|
|
6
|
+
if (er) console.log(files, "glob resolving issue");
|
|
7
|
+
else files.forEach((filename) => update(filename));
|
|
10
8
|
}
|
|
11
9
|
|
|
12
|
-
|
|
13
10
|
function update(mdPath) {
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
fs.unlinkSync(mdPath)
|
|
31
|
-
fs.writeFileSync(mdPath, replaced)
|
|
32
|
-
|
|
33
|
-
|
|
11
|
+
// component name
|
|
12
|
+
// console.log(mdPath);
|
|
13
|
+
let nameDir = mdPath;
|
|
14
|
+
do {
|
|
15
|
+
nameDir = path.dirname(nameDir);
|
|
16
|
+
} while (!path.basename(nameDir).startsWith("CoCreate-"));
|
|
17
|
+
let name = path.basename(nameDir).substring(9);
|
|
18
|
+
// console.log(name);
|
|
19
|
+
// process.exit();
|
|
20
|
+
let replaceContent = fs.readFileSync(mdPath).toString();
|
|
21
|
+
|
|
22
|
+
console.log(replaceContent, name);
|
|
23
|
+
let replaced = replaceContent.replace(/boilerplate/gi, name);
|
|
24
|
+
|
|
25
|
+
if (fs.existsSync(mdPath)) fs.unlinkSync(mdPath);
|
|
26
|
+
fs.writeFileSync(mdPath, replaced);
|
|
34
27
|
}
|
|
35
28
|
|
|
36
|
-
|
|
37
|
-
glob("./docs/", globUpdater)
|
|
29
|
+
glob("./docs/", globUpdater);
|
|
38
30
|
// glob("../CoCreate-docs/docs/*.html", globUpdater)
|
|
39
|
-
// glob("../CoCreate-
|
|
31
|
+
// glob("../CoCreate-modules/*/docs/*.html", globUpdater)
|
|
40
32
|
// glob("../CoCreate-apps/*/docs/*.html", globUpdater)
|
|
41
33
|
// glob("../CoCreate-plugins/*/docs/*.html", globUpdater)
|
|
42
34
|
|
|
43
|
-
console.log(
|
|
35
|
+
console.log("finished");
|