@cocreate/cli 1.48.0 → 1.50.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/.github/workflows/automated.yml +0 -1
- package/CHANGELOG.md +40 -0
- package/CoCreate.config.js +499 -420
- package/docs/index.html +250 -250
- package/package.json +5 -7
- package/prettier.config.js +18 -0
- package/src/addMeta.js +74 -67
- package/src/coc.js +129 -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 +81 -31
- package/src/commands/fs/config.js +94 -38
- package/src/commands/fs/gitignore.js +13 -22
- package/src/commands/fs/manual.js +17 -27
- package/src/commands/fs/prettier.config.js +99 -0
- 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
|
+
};
|
|
@@ -1,26 +1,65 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
1
|
+
const fs = require("fs");
|
|
2
|
+
const path = require("path");
|
|
3
3
|
|
|
4
|
-
function
|
|
4
|
+
function findDirectories(startPath, callback, fileName) {
|
|
5
|
+
// Resolve relative paths to absolute paths if needed
|
|
6
|
+
const resolvedPath =
|
|
7
|
+
startPath.startsWith("./") || startPath.startsWith("../")
|
|
8
|
+
? path.resolve(startPath)
|
|
9
|
+
: startPath;
|
|
5
10
|
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
11
|
+
const segments = resolvedPath.split("/"); // Split path by '/'
|
|
12
|
+
let currentPath = "/"; // Start from root
|
|
13
|
+
|
|
14
|
+
for (let i = 0; i < segments.length; i++) {
|
|
15
|
+
const segment = segments[i];
|
|
16
|
+
const isWildcard = segment === "*";
|
|
17
|
+
|
|
18
|
+
if (isWildcard) {
|
|
19
|
+
// Get all directories at this level
|
|
20
|
+
const directories = fs
|
|
21
|
+
.readdirSync(currentPath)
|
|
22
|
+
.filter((file) =>
|
|
23
|
+
fs.statSync(path.join(currentPath, file)).isDirectory()
|
|
24
|
+
);
|
|
25
|
+
|
|
26
|
+
// Process each directory and continue along the path
|
|
27
|
+
directories.forEach((dir) => {
|
|
28
|
+
findDirectories(
|
|
29
|
+
path.join(currentPath, dir, ...segments.slice(i + 1)),
|
|
30
|
+
callback,
|
|
31
|
+
fileName
|
|
32
|
+
);
|
|
33
|
+
});
|
|
34
|
+
return; // Stop further processing in the loop for wildcard case
|
|
35
|
+
} else {
|
|
36
|
+
// Continue to the next part of the path
|
|
37
|
+
currentPath = path.join(currentPath, segment);
|
|
38
|
+
|
|
39
|
+
// If a segment doesn’t exist or isn’t a directory, log an error and stop
|
|
40
|
+
if (
|
|
41
|
+
!fs.existsSync(currentPath) ||
|
|
42
|
+
!fs.statSync(currentPath).isDirectory()
|
|
43
|
+
) {
|
|
44
|
+
console.log(`Directory not found: ${currentPath}`);
|
|
45
|
+
return;
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
// If we reach the end of the path without wildcards, we have a valid directory
|
|
51
|
+
callback(currentPath, fileName);
|
|
13
52
|
}
|
|
14
53
|
|
|
15
|
-
function
|
|
16
|
-
|
|
17
|
-
run: yarn build`
|
|
54
|
+
function createOrUpdateFile(directoryPath, fileName) {
|
|
55
|
+
let buildStep = `- name: Build\n run: yarn build`;
|
|
18
56
|
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
57
|
+
// Check if webpack config exists to include build step
|
|
58
|
+
const webpackPath = filePath.replace(fileName, "webpack.config.js");
|
|
59
|
+
if (!fs.existsSync(webpackPath)) buildStep = "";
|
|
22
60
|
|
|
23
|
-
|
|
61
|
+
// Define file content (e.g., for YAML or other configuration)
|
|
62
|
+
const fileContent = `name: Automated Workflow
|
|
24
63
|
on:
|
|
25
64
|
push:
|
|
26
65
|
branches:
|
|
@@ -80,7 +119,7 @@ jobs:
|
|
|
80
119
|
run: echo "//registry.npmjs.org/:_authToken=\${{ secrets.NPM_TOKEN }}" > ~/.npmrc
|
|
81
120
|
- name: Install dependencies
|
|
82
121
|
run: yarn install
|
|
83
|
-
${
|
|
122
|
+
${buildStep}
|
|
84
123
|
- name: Set Environment Variables
|
|
85
124
|
run: |
|
|
86
125
|
echo "organization_id=\${{ secrets.COCREATE_ORGANIZATION_ID }}" >> $GITHUB_ENV
|
|
@@ -88,22 +127,33 @@ jobs:
|
|
|
88
127
|
echo "host=\${{ secrets.COCREATE_HOST }}" >> $GITHUB_ENV
|
|
89
128
|
- name: CoCreate Upload
|
|
90
129
|
run: coc upload
|
|
91
|
-
|
|
92
130
|
`;
|
|
93
|
-
if (fs.existsSync(YmlPath))
|
|
94
|
-
fs.unlinkSync(YmlPath)
|
|
95
|
-
fs.writeFileSync(YmlPath, fileContent)
|
|
96
131
|
|
|
132
|
+
const filePath = path.join(directoryPath, fileName);
|
|
133
|
+
// Create or update the file
|
|
134
|
+
if (fs.existsSync(filePath)) fs.unlinkSync(filePath);
|
|
135
|
+
fs.writeFileSync(filePath, fileContent);
|
|
97
136
|
}
|
|
98
137
|
|
|
138
|
+
// Define the directories with wildcards
|
|
139
|
+
const directories = [
|
|
140
|
+
"../../../../../CoCreate-modules/*/",
|
|
141
|
+
"../../../../../CoCreate-apps/*/",
|
|
142
|
+
"../../../../../CoCreate-plugins/*/",
|
|
143
|
+
"../../../../../CoCreateCSS/",
|
|
144
|
+
"../../../../../CoCreateJS/",
|
|
145
|
+
"../../../../../CoCreateWS/",
|
|
146
|
+
"../../../../../YellowOracle/",
|
|
147
|
+
"../../../../../CoCreate-website/",
|
|
148
|
+
"../../../../../CoCreate-admin/",
|
|
149
|
+
"../../../../../CoCreate-website-old/",
|
|
150
|
+
"../../../../../CoCreate-superadmin/",
|
|
151
|
+
];
|
|
152
|
+
const fileName = "automated.yml";
|
|
99
153
|
|
|
154
|
+
// Execute directory search and create/update file if the directory exists
|
|
155
|
+
directories.forEach((directory) => {
|
|
156
|
+
findDirectories(directory, createOrUpdateFile, fileName);
|
|
157
|
+
});
|
|
100
158
|
|
|
101
|
-
|
|
102
|
-
glob("/home/cocreate/CoCreate/CoCreate-components/*/.github/workflows/", globUpdater)
|
|
103
|
-
// glob("/home/cocreate/CoCreate/CoCreate-apps/*/.github/workflows/", globUpdater)
|
|
104
|
-
// glob("/home/cocreate/CoCreate/CoCreate-plugins/*/.github/workflows/", globUpdater)
|
|
105
|
-
|
|
106
|
-
// glob("/home/cocreate/CoCreate/CoCreate-admin/.github/workflows/", globUpdater)
|
|
107
|
-
// glob("/home/cocreate/CoCreate/CoCreateCSS/.github/workflows/", globUpdater)
|
|
108
|
-
// glob("/home/cocreate/CoCreate/CoCreateJS/.github/workflows/", globUpdater)
|
|
109
|
-
// glob("/home/cocreate/CoCreate/CoCreate-wesite/.github/workflows/", globUpdater)
|
|
159
|
+
console.log("Finished");
|
|
@@ -1,30 +1,72 @@
|
|
|
1
|
-
|
|
2
|
-
let fs = require('fs');
|
|
1
|
+
const fs = require("fs");
|
|
3
2
|
const path = require("path");
|
|
4
3
|
|
|
5
|
-
function
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
4
|
+
function findDirectories(startPath, callback, fileName) {
|
|
5
|
+
// Resolve relative paths to absolute paths if needed
|
|
6
|
+
const resolvedPath =
|
|
7
|
+
startPath.startsWith("./") || startPath.startsWith("../")
|
|
8
|
+
? path.resolve(startPath)
|
|
9
|
+
: startPath;
|
|
11
10
|
|
|
11
|
+
const segments = resolvedPath.split("/"); // Split path by '/'
|
|
12
|
+
let currentPath = "/"; // Start from root
|
|
12
13
|
|
|
14
|
+
for (let i = 0; i < segments.length; i++) {
|
|
15
|
+
const segment = segments[i];
|
|
16
|
+
const isWildcard = segment === "*";
|
|
13
17
|
|
|
18
|
+
if (isWildcard) {
|
|
19
|
+
// Get all directories at this level
|
|
20
|
+
const directories = fs
|
|
21
|
+
.readdirSync(currentPath)
|
|
22
|
+
.filter((file) =>
|
|
23
|
+
fs.statSync(path.join(currentPath, file)).isDirectory()
|
|
24
|
+
);
|
|
14
25
|
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
26
|
+
// Process each directory and continue along the path
|
|
27
|
+
directories.forEach((dir) => {
|
|
28
|
+
findDirectories(
|
|
29
|
+
path.join(currentPath, dir, ...segments.slice(i + 1)),
|
|
30
|
+
callback,
|
|
31
|
+
fileName
|
|
32
|
+
);
|
|
33
|
+
});
|
|
34
|
+
return; // Stop further processing in the loop for wildcard case
|
|
35
|
+
} else {
|
|
36
|
+
// Continue to the next part of the path
|
|
37
|
+
currentPath = path.join(currentPath, segment);
|
|
19
38
|
|
|
39
|
+
// If a segment doesn’t exist or isn’t a directory, log an error and stop
|
|
40
|
+
if (
|
|
41
|
+
!fs.existsSync(currentPath) ||
|
|
42
|
+
!fs.statSync(currentPath).isDirectory()
|
|
43
|
+
) {
|
|
44
|
+
console.log(`Directory not found: ${currentPath}`);
|
|
45
|
+
return;
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
}
|
|
20
49
|
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
object = content2.substring(3, content2.indexOf(',') - 4);
|
|
50
|
+
// If we reach the end of the path without wildcards, we have a valid directory
|
|
51
|
+
callback(currentPath, fileName);
|
|
52
|
+
}
|
|
25
53
|
|
|
54
|
+
function createOrUpdateFile(directoryPath, fileName) {
|
|
55
|
+
let name = path
|
|
56
|
+
.basename(path.resolve(path.dirname(directoryPath), "./"))
|
|
57
|
+
.substring(9);
|
|
58
|
+
let object = "";
|
|
59
|
+
let replaceContent = fs.readFileSync(directoryPath).toString();
|
|
26
60
|
|
|
27
|
-
|
|
61
|
+
// Parse content to extract `object`
|
|
62
|
+
let content_source = replaceContent.substring(
|
|
63
|
+
replaceContent.indexOf("sources")
|
|
64
|
+
);
|
|
65
|
+
let content1 = content_source.substring(content_source.indexOf("object"));
|
|
66
|
+
let content2 = content1.substring(content1.indexOf(":"));
|
|
67
|
+
object = content2.substring(3, content2.indexOf(",") - 4);
|
|
68
|
+
|
|
69
|
+
let fileContent = `module.exports = {
|
|
28
70
|
"config": {
|
|
29
71
|
"organization_id": "5ff747727005da1c272740ab",
|
|
30
72
|
"key": "2061acef-0451-4545-f754-60cf8160",
|
|
@@ -37,7 +79,7 @@ function update(MdPath) {
|
|
|
37
79
|
"object": {
|
|
38
80
|
"_id": "${object}",
|
|
39
81
|
"name": "index.html",
|
|
40
|
-
|
|
82
|
+
"path": "/docs/${name}",
|
|
41
83
|
"pathname": "/docs/${name}/index.html",
|
|
42
84
|
"src": "{{./docs/index.html}}",
|
|
43
85
|
"host": [
|
|
@@ -50,28 +92,42 @@ function update(MdPath) {
|
|
|
50
92
|
}
|
|
51
93
|
]
|
|
52
94
|
}
|
|
53
|
-
|
|
54
95
|
`;
|
|
55
96
|
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
97
|
+
if (!object.length) {
|
|
98
|
+
console.log("object Undefined: ", directoryPath);
|
|
99
|
+
} else if (object.length !== 24) {
|
|
100
|
+
console.log("object not valid! Please check your config: ", directoryPath);
|
|
101
|
+
} else {
|
|
102
|
+
const filePath = path.join(directoryPath, fileName);
|
|
103
|
+
if (fs.existsSync(filePath)) fs.unlinkSync(filePath);
|
|
104
|
+
fs.writeFileSync(filePath, fileContent);
|
|
105
|
+
}
|
|
106
|
+
const filePath = path.join(directoryPath, fileName);
|
|
107
|
+
// Create or update the file
|
|
108
|
+
if (fs.existsSync(filePath)) fs.unlinkSync(filePath);
|
|
109
|
+
fs.writeFileSync(filePath, fileContent);
|
|
68
110
|
}
|
|
69
111
|
|
|
70
|
-
//
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
112
|
+
// Define the directories with wildcards
|
|
113
|
+
const directories = [
|
|
114
|
+
"../../../../../CoCreate-modules/*/",
|
|
115
|
+
"../../../../../CoCreate-apps/*/",
|
|
116
|
+
"../../../../../CoCreate-plugins/*/",
|
|
117
|
+
"../../../../../CoCreateCSS/",
|
|
118
|
+
"../../../../../CoCreateJS/",
|
|
119
|
+
"../../../../../CoCreateWS/",
|
|
120
|
+
"../../../../../YellowOracle/",
|
|
121
|
+
"../../../../../CoCreate-website/",
|
|
122
|
+
"../../../../../CoCreate-admin/",
|
|
123
|
+
"../../../../../CoCreate-website-old/",
|
|
124
|
+
"../../../../../CoCreate-superadmin/",
|
|
125
|
+
];
|
|
126
|
+
const fileName = "CoCreate.config.js";
|
|
127
|
+
|
|
128
|
+
// Execute directory search and create/update file if the directory exists
|
|
129
|
+
directories.forEach((directory) => {
|
|
130
|
+
findDirectories(directory, createOrUpdateFile, fileName);
|
|
131
|
+
});
|
|
76
132
|
|
|
77
|
-
console.log(
|
|
133
|
+
console.log("Finished");
|
|
@@ -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");
|