@cocreate/cli 1.60.0 → 1.64.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/CoCreate.config.js +7 -160
- package/package.json +4 -22
- package/src/commands/link.js +268 -92
- package/src/commands/other/lazyload-modules.js +753 -0
- package/src/commands/storage.js +126 -0
- package/src/commands/upload.js +4 -0
- package/src/commands/fs/automated.js +0 -159
- package/src/commands/fs/config.js +0 -133
- package/src/commands/fs/manual.js +0 -81
- package/src/commands/fs/prettier.config.js +0 -99
- package/src/commands/fs/readme.js +0 -138
- package/src/commands/fs/remove.js +0 -24
- package/src/commands/fs/replace.js +0 -35
|
@@ -0,0 +1,126 @@
|
|
|
1
|
+
const fs = require("fs");
|
|
2
|
+
const path = require("path");
|
|
3
|
+
const { getConfig } = require("../getConfig");
|
|
4
|
+
|
|
5
|
+
module.exports = async function storage(directory, args) {
|
|
6
|
+
if (args && !Array.isArray(args)) args = [args];
|
|
7
|
+
|
|
8
|
+
const isWatch =
|
|
9
|
+
args &&
|
|
10
|
+
(args.includes("-w") || args.includes("--watch"));
|
|
11
|
+
|
|
12
|
+
const cwd = process.cwd();
|
|
13
|
+
|
|
14
|
+
// CRUD Server storage directory
|
|
15
|
+
const storageDestinationDirectory = path.resolve(cwd, "storage");
|
|
16
|
+
|
|
17
|
+
await fs.promises.mkdir(storageDestinationDirectory, {
|
|
18
|
+
recursive: true
|
|
19
|
+
});
|
|
20
|
+
|
|
21
|
+
const config = await getConfig(cwd);
|
|
22
|
+
|
|
23
|
+
if (!config || !config.modules) {
|
|
24
|
+
console.error("Failed to read or parse CoCreate.config.js.");
|
|
25
|
+
return;
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
const storages = [];
|
|
29
|
+
|
|
30
|
+
for (const module of Object.values(config.modules)) {
|
|
31
|
+
if (!module.path) continue;
|
|
32
|
+
|
|
33
|
+
const normalizedPath = path.normalize(module.path);
|
|
34
|
+
|
|
35
|
+
// Only process storage repositories
|
|
36
|
+
if (
|
|
37
|
+
!normalizedPath.includes(
|
|
38
|
+
`${path.sep}CoCreate-storages${path.sep}`
|
|
39
|
+
)
|
|
40
|
+
)
|
|
41
|
+
continue;
|
|
42
|
+
|
|
43
|
+
// Repository name (ex: CoCreate-mongodb)
|
|
44
|
+
const repositoryName = path.basename(normalizedPath);
|
|
45
|
+
|
|
46
|
+
// Storage name (ex: mongodb)
|
|
47
|
+
const storageName = repositoryName.replace(/^CoCreate-/, "");
|
|
48
|
+
|
|
49
|
+
storages.push({
|
|
50
|
+
name: storageName,
|
|
51
|
+
storageSource: path.resolve(
|
|
52
|
+
module.path,
|
|
53
|
+
"dist",
|
|
54
|
+
`${storageName}.js`
|
|
55
|
+
),
|
|
56
|
+
storageDestination: path.resolve(
|
|
57
|
+
storageDestinationDirectory,
|
|
58
|
+
`${storageName}.js`
|
|
59
|
+
)
|
|
60
|
+
});
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
if (!storages.length) {
|
|
64
|
+
console.log("No storage repositories found.");
|
|
65
|
+
return;
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
// Initial copy
|
|
69
|
+
for (const storage of storages) {
|
|
70
|
+
await copyStorage(storage);
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
if (!isWatch) return;
|
|
74
|
+
|
|
75
|
+
console.log("\nWatching storage files...\n");
|
|
76
|
+
|
|
77
|
+
for (const storage of storages) {
|
|
78
|
+
if (!fs.existsSync(storage.storageSource)) {
|
|
79
|
+
console.warn(
|
|
80
|
+
`Storage source not found: ${storage.storageSource}`
|
|
81
|
+
);
|
|
82
|
+
continue;
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
let debounce;
|
|
86
|
+
|
|
87
|
+
fs.watch(storage.storageSource, (eventType) => {
|
|
88
|
+
if (eventType !== "change") return;
|
|
89
|
+
|
|
90
|
+
clearTimeout(debounce);
|
|
91
|
+
|
|
92
|
+
debounce = setTimeout(async () => {
|
|
93
|
+
await copyStorage(storage);
|
|
94
|
+
}, 100);
|
|
95
|
+
});
|
|
96
|
+
|
|
97
|
+
console.log(
|
|
98
|
+
`Watching ${storage.name}: ${storage.storageSource}`
|
|
99
|
+
);
|
|
100
|
+
}
|
|
101
|
+
};
|
|
102
|
+
|
|
103
|
+
async function copyStorage(storage) {
|
|
104
|
+
try {
|
|
105
|
+
if (!fs.existsSync(storage.storageSource)) {
|
|
106
|
+
console.warn(
|
|
107
|
+
`Storage source not found: ${storage.storageSource}`
|
|
108
|
+
);
|
|
109
|
+
return;
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
await fs.promises.copyFile(
|
|
113
|
+
storage.storageSource,
|
|
114
|
+
storage.storageDestination
|
|
115
|
+
);
|
|
116
|
+
|
|
117
|
+
console.log(
|
|
118
|
+
`Copied ${storage.name}.js`
|
|
119
|
+
);
|
|
120
|
+
} catch (err) {
|
|
121
|
+
console.error(
|
|
122
|
+
`Failed copying ${storage.name}:`,
|
|
123
|
+
err.message
|
|
124
|
+
);
|
|
125
|
+
}
|
|
126
|
+
}
|
package/src/commands/upload.js
CHANGED
|
@@ -2,6 +2,10 @@ let fileModule = require("@cocreate/file");
|
|
|
2
2
|
// Safely resolve default export if it's wrapped as an ESM module
|
|
3
3
|
const file = fileModule && fileModule.default ? fileModule.default : fileModule;
|
|
4
4
|
|
|
5
|
+
// Required to watch more files than the default limit on Linux systems. You may need to run these commands in your terminal:
|
|
6
|
+
// echo "fs.inotify.max_user_watches=524288" | sudo tee -a /etc/sysctl.conf
|
|
7
|
+
// echo "fs.inotify.max_user_instances=1024" | sudo tee -a /etc/sysctl.conf
|
|
8
|
+
// sudo sysctl -p
|
|
5
9
|
const path = require("path");
|
|
6
10
|
const fs = require("fs");
|
|
7
11
|
const { getConfig } = require("../getConfig");
|
|
@@ -1,159 +0,0 @@
|
|
|
1
|
-
const fs = require("fs");
|
|
2
|
-
const path = require("path");
|
|
3
|
-
|
|
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;
|
|
10
|
-
|
|
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);
|
|
52
|
-
}
|
|
53
|
-
|
|
54
|
-
function createOrUpdateFile(directoryPath, fileName) {
|
|
55
|
-
let buildStep = `- name: Build\n run: yarn build`;
|
|
56
|
-
|
|
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 = "";
|
|
60
|
-
|
|
61
|
-
// Define file content (e.g., for YAML or other configuration)
|
|
62
|
-
const fileContent = `name: Automated Workflow
|
|
63
|
-
on:
|
|
64
|
-
push:
|
|
65
|
-
branches:
|
|
66
|
-
- main
|
|
67
|
-
jobs:
|
|
68
|
-
about:
|
|
69
|
-
runs-on: ubuntu-latest
|
|
70
|
-
steps:
|
|
71
|
-
- name: Checkout
|
|
72
|
-
uses: actions/checkout@v3
|
|
73
|
-
- name: Setup Node.js
|
|
74
|
-
uses: actions/setup-node@v3
|
|
75
|
-
with:
|
|
76
|
-
node-version: 16
|
|
77
|
-
- name: Jaid/action-sync-node-meta
|
|
78
|
-
uses: jaid/action-sync-node-meta@v1.4.0
|
|
79
|
-
with:
|
|
80
|
-
direction: overwrite-github
|
|
81
|
-
githubToken: "\${{ secrets.GITHUB }}"
|
|
82
|
-
release:
|
|
83
|
-
runs-on: ubuntu-latest
|
|
84
|
-
steps:
|
|
85
|
-
- name: Checkout
|
|
86
|
-
uses: actions/checkout@v3
|
|
87
|
-
- name: Setup Node.js
|
|
88
|
-
uses: actions/setup-node@v3
|
|
89
|
-
with:
|
|
90
|
-
node-version: 14
|
|
91
|
-
- name: Semantic Release
|
|
92
|
-
uses: cycjimmy/semantic-release-action@v3
|
|
93
|
-
id: semantic
|
|
94
|
-
with:
|
|
95
|
-
extra_plugins: |
|
|
96
|
-
@semantic-release/changelog
|
|
97
|
-
@semantic-release/git
|
|
98
|
-
@semantic-release/github
|
|
99
|
-
env:
|
|
100
|
-
GITHUB_TOKEN: "\${{ secrets.GITHUB }}"
|
|
101
|
-
NPM_TOKEN: "\${{ secrets.NPM_TOKEN }}"
|
|
102
|
-
outputs:
|
|
103
|
-
new_release_published: "\${{ steps.semantic.outputs.new_release_published }}"
|
|
104
|
-
new_release_version: "\${{ steps.semantic.outputs.new_release_version }}"
|
|
105
|
-
upload:
|
|
106
|
-
runs-on: ubuntu-latest
|
|
107
|
-
needs: release
|
|
108
|
-
if: needs.release.outputs.new_release_published == 'true'
|
|
109
|
-
env:
|
|
110
|
-
VERSION: "\${{ needs.release.outputs.new_release_version }}"
|
|
111
|
-
steps:
|
|
112
|
-
- name: Checkout
|
|
113
|
-
uses: actions/checkout@v3
|
|
114
|
-
- name: Setup Node.js
|
|
115
|
-
uses: actions/setup-node@v3
|
|
116
|
-
with:
|
|
117
|
-
node-version: 16
|
|
118
|
-
- name: Set npm registry auth
|
|
119
|
-
run: echo "//registry.npmjs.org/:_authToken=\${{ secrets.NPM_TOKEN }}" > ~/.npmrc
|
|
120
|
-
- name: Install dependencies
|
|
121
|
-
run: yarn install
|
|
122
|
-
${buildStep}
|
|
123
|
-
- name: Set Environment Variables
|
|
124
|
-
run: |
|
|
125
|
-
echo "organization_id=\${{ secrets.COCREATE_ORGANIZATION_ID }}" >> $GITHUB_ENV
|
|
126
|
-
echo "key=\${{ secrets.COCREATE_KEY }}" >> $GITHUB_ENV
|
|
127
|
-
echo "host=\${{ secrets.COCREATE_HOST }}" >> $GITHUB_ENV
|
|
128
|
-
- name: CoCreate Upload
|
|
129
|
-
run: coc upload
|
|
130
|
-
`;
|
|
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);
|
|
136
|
-
}
|
|
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";
|
|
153
|
-
|
|
154
|
-
// Execute directory search and create/update file if the directory exists
|
|
155
|
-
directories.forEach((directory) => {
|
|
156
|
-
findDirectories(directory, createOrUpdateFile, fileName);
|
|
157
|
-
});
|
|
158
|
-
|
|
159
|
-
console.log("Finished");
|
|
@@ -1,133 +0,0 @@
|
|
|
1
|
-
const fs = require("fs");
|
|
2
|
-
const path = require("path");
|
|
3
|
-
|
|
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;
|
|
10
|
-
|
|
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);
|
|
52
|
-
}
|
|
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();
|
|
60
|
-
|
|
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 = {
|
|
70
|
-
"config": {
|
|
71
|
-
"organization_id": "5ff747727005da1c272740ab",
|
|
72
|
-
"key": "2061acef-0451-4545-f754-60cf8160",
|
|
73
|
-
"host": "general.cocreate.app"
|
|
74
|
-
},
|
|
75
|
-
|
|
76
|
-
"sources": [
|
|
77
|
-
{
|
|
78
|
-
"array": "files",
|
|
79
|
-
"object": {
|
|
80
|
-
"_id": "${object}",
|
|
81
|
-
"name": "index.html",
|
|
82
|
-
"path": "/docs/${name}",
|
|
83
|
-
"pathname": "/docs/${name}/index.html",
|
|
84
|
-
"src": "{{./docs/index.html}}",
|
|
85
|
-
"host": [
|
|
86
|
-
"general.cocreate.app"
|
|
87
|
-
],
|
|
88
|
-
"directory": "${name}",
|
|
89
|
-
"content-type": "{{content-type}}",
|
|
90
|
-
"public": "true"
|
|
91
|
-
}
|
|
92
|
-
}
|
|
93
|
-
]
|
|
94
|
-
}
|
|
95
|
-
`;
|
|
96
|
-
|
|
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);
|
|
110
|
-
}
|
|
111
|
-
|
|
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
|
-
});
|
|
132
|
-
|
|
133
|
-
console.log("Finished");
|
|
@@ -1,81 +0,0 @@
|
|
|
1
|
-
let glob = require("glob");
|
|
2
|
-
let fs = require("fs");
|
|
3
|
-
const path = require("path");
|
|
4
|
-
|
|
5
|
-
function globUpdater(er, files) {
|
|
6
|
-
if (er) console.log(files, "glob resolving issue");
|
|
7
|
-
else
|
|
8
|
-
files.forEach((filename) => {
|
|
9
|
-
console.log(filename + "/manual.yml", "glob resolving issue");
|
|
10
|
-
update(filename + "/manual.yml");
|
|
11
|
-
});
|
|
12
|
-
}
|
|
13
|
-
|
|
14
|
-
function update(Path) {
|
|
15
|
-
// component name
|
|
16
|
-
let name = path
|
|
17
|
-
.basename(path.resolve(path.dirname(Path), "../.."))
|
|
18
|
-
.substring(9);
|
|
19
|
-
let fileContent = `name: Manual Workflow
|
|
20
|
-
on:
|
|
21
|
-
workflow_dispatch:
|
|
22
|
-
inputs:
|
|
23
|
-
invalidations:
|
|
24
|
-
description: |
|
|
25
|
-
If set to 'true', invalidates previous upload.
|
|
26
|
-
default: 'true'
|
|
27
|
-
required: true
|
|
28
|
-
|
|
29
|
-
jobs:
|
|
30
|
-
cdn:
|
|
31
|
-
runs-on: ubuntu-latest
|
|
32
|
-
env:
|
|
33
|
-
DRY_RUN: \${{ github.event.inputs.dry_run }}
|
|
34
|
-
GITHUB_TOKEN: '\${{ secrets.GITHUB_TOKEN }}'
|
|
35
|
-
NPM_TOKEN: '\${{ secrets.NPM_TOKEN }}'
|
|
36
|
-
|
|
37
|
-
steps:
|
|
38
|
-
- name: Checkout
|
|
39
|
-
uses: actions/checkout@v3
|
|
40
|
-
- name: setup nodejs
|
|
41
|
-
uses: actions/setup-node@v3
|
|
42
|
-
with:
|
|
43
|
-
node-version: 16
|
|
44
|
-
- name: yarn install
|
|
45
|
-
run: >
|
|
46
|
-
echo "//registry.npmjs.org/:_authToken=\${{ secrets.NPM_TOKEN }}" >
|
|
47
|
-
.npmrc
|
|
48
|
-
|
|
49
|
-
yarn install
|
|
50
|
-
- name: yarn build
|
|
51
|
-
run: yarn build
|
|
52
|
-
- name: upload latest bundle
|
|
53
|
-
uses: CoCreate-app/CoCreate-s3@master
|
|
54
|
-
with:
|
|
55
|
-
aws-key-id: '\${{ secrets.AWSACCESSKEYID }}'
|
|
56
|
-
aws-access-key: '\${{ secrets.AWSSECERTACCESSKEY }}'
|
|
57
|
-
distributionId: '\${{ secrets.DISTRIBUTION_ID }}'
|
|
58
|
-
bucket: testcrudbucket
|
|
59
|
-
source: ./dist
|
|
60
|
-
destination: /${name}/latest
|
|
61
|
-
acl: public-read
|
|
62
|
-
invalidations: \${{ github.event.inputs.invalidations }}
|
|
63
|
-
|
|
64
|
-
`;
|
|
65
|
-
|
|
66
|
-
if (fs.existsSync(Path)) fs.unlinkSync(Path);
|
|
67
|
-
fs.writeFileSync(Path, fileContent);
|
|
68
|
-
}
|
|
69
|
-
|
|
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);
|
|
74
|
-
|
|
75
|
-
// substrin (9) removes CoCreateC leving namme as SS
|
|
76
|
-
// glob("../CoCreateCSS/.github/workflows/", globUpdater)
|
|
77
|
-
|
|
78
|
-
// does not need to add name... will require for name to be removed from destination
|
|
79
|
-
// glob("../CoCreateJS/.github/workflows/", globUpdater)
|
|
80
|
-
|
|
81
|
-
console.log("finished");
|
|
@@ -1,99 +0,0 @@
|
|
|
1
|
-
const fs = require("fs");
|
|
2
|
-
const path = require("path");
|
|
3
|
-
|
|
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;
|
|
10
|
-
|
|
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);
|
|
52
|
-
}
|
|
53
|
-
|
|
54
|
-
function createOrUpdateFile(directoryPath, fileName) {
|
|
55
|
-
const fileContent = `module.exports = {
|
|
56
|
-
tabWidth: 4,
|
|
57
|
-
semi: true,
|
|
58
|
-
trailingComma: "none",
|
|
59
|
-
bracketSameLine: true,
|
|
60
|
-
useTabs: true,
|
|
61
|
-
overrides: [
|
|
62
|
-
{
|
|
63
|
-
files: ["*.json", "*.yml", "*.yaml"],
|
|
64
|
-
options: {
|
|
65
|
-
tabWidth: 2,
|
|
66
|
-
useTabs: false
|
|
67
|
-
},
|
|
68
|
-
}
|
|
69
|
-
],
|
|
70
|
-
};`;
|
|
71
|
-
|
|
72
|
-
const filePath = path.join(directoryPath, fileName);
|
|
73
|
-
// Create or update the file
|
|
74
|
-
if (fs.existsSync(filePath)) fs.unlinkSync(filePath);
|
|
75
|
-
fs.writeFileSync(filePath, fileContent);
|
|
76
|
-
}
|
|
77
|
-
|
|
78
|
-
// Define the directories with wildcards
|
|
79
|
-
const directories = [
|
|
80
|
-
"../../../../../CoCreate-modules/*/",
|
|
81
|
-
"../../../../../CoCreate-apps/*/",
|
|
82
|
-
"../../../../../CoCreate-plugins/*/",
|
|
83
|
-
"../../../../../CoCreateCSS/",
|
|
84
|
-
"../../../../../CoCreateJS/",
|
|
85
|
-
"../../../../../CoCreateWS/",
|
|
86
|
-
"../../../../../YellowOracle/",
|
|
87
|
-
"../../../../../CoCreate-website/",
|
|
88
|
-
"../../../../../CoCreate-admin/",
|
|
89
|
-
"../../../../../CoCreate-website-old/",
|
|
90
|
-
"../../../../../CoCreate-superadmin/",
|
|
91
|
-
];
|
|
92
|
-
const fileName = "prettier.config.js";
|
|
93
|
-
|
|
94
|
-
// Execute directory search and create/update file if the directory exists
|
|
95
|
-
directories.forEach((directory) => {
|
|
96
|
-
findDirectories(directory, createOrUpdateFile, fileName);
|
|
97
|
-
});
|
|
98
|
-
|
|
99
|
-
console.log("Finished");
|