@atomicsmash/cli 10.0.0-beta.0 → 10.0.0-beta.2
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/dist/commands/pull-database.d.ts.map +1 -1
- package/dist/commands/pull-database.js +2 -1
- package/dist/commands/setup-database.d.ts.map +1 -1
- package/dist/commands/setup-database.js +17 -10
- package/dist/commands/setup.d.ts.map +1 -1
- package/dist/commands/setup.js +12 -8
- package/dist/index.d.ts +1 -15
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +1 -1
- package/dist/utils.d.ts +0 -10
- package/dist/utils.d.ts.map +1 -1
- package/dist/utils.js +1 -93
- package/package.json +2 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"pull-database.d.ts","sourceRoot":"","sources":["../../src/commands/pull-database.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"pull-database.d.ts","sourceRoot":"","sources":["../../src/commands/pull-database.ts"],"names":[],"mappings":"AAOA,eAAO,MAAM,OAAO,kBAAkB,CAAC;AACvC,eAAO,MAAM,QAAQ,oEAC6C,CAAC;AACnE,wBAAsB,OAAO,kBA4I5B"}
|
|
@@ -2,7 +2,8 @@ import { exec } from "node:child_process";
|
|
|
2
2
|
import { unlink as deleteFile } from "node:fs/promises";
|
|
3
3
|
import { performance } from "node:perf_hooks";
|
|
4
4
|
import { promisify } from "node:util";
|
|
5
|
-
import {
|
|
5
|
+
import { getSmashConfig } from "@atomicsmash/smash-config";
|
|
6
|
+
import { convertMeasureToPrettyString, startRunningMessage } from "../utils.js";
|
|
6
7
|
export const command = "pull-database";
|
|
7
8
|
export const describe = "Pull the database down from staging and replace local database.";
|
|
8
9
|
export async function handler() {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"setup-database.d.ts","sourceRoot":"","sources":["../../src/commands/setup-database.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"setup-database.d.ts","sourceRoot":"","sources":["../../src/commands/setup-database.ts"],"names":[],"mappings":"AAKA,OAAO,eAAe,CAAC;AA+EvB,eAAO,MAAM,OAAO,mBAAmB,CAAC;AACxC,eAAO,MAAM,QAAQ,mEAC4C,CAAC;AAClE,wBAAsB,OAAO,kBAgH5B"}
|
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
import { exec } from "node:child_process";
|
|
2
2
|
import { performance } from "node:perf_hooks";
|
|
3
3
|
import { promisify } from "node:util";
|
|
4
|
-
import {
|
|
4
|
+
import { getSmashConfig } from "@atomicsmash/smash-config";
|
|
5
|
+
import { convertMeasureToPrettyString, startRunningMessage } from "../utils.js";
|
|
5
6
|
import "dotenv/config";
|
|
6
7
|
function extractDependenciesFromError(errorMessage) {
|
|
7
8
|
// Extract plugin names from error messages like:
|
|
@@ -9,7 +10,7 @@ function extractDependenciesFromError(errorMessage) {
|
|
|
9
10
|
const regex = /requires \d+ plugin[s]? to be installed and activated: (.+)\./;
|
|
10
11
|
const match = regex.exec(errorMessage);
|
|
11
12
|
if (match?.[1]) {
|
|
12
|
-
return match[1].split(
|
|
13
|
+
return match[1].split(",").map((dep) => dep.trim());
|
|
13
14
|
}
|
|
14
15
|
return [];
|
|
15
16
|
}
|
|
@@ -33,10 +34,11 @@ async function activatePluginsWithRetry(execute, pluginsToActivate, excludedPlug
|
|
|
33
34
|
// Check if this is a dependency error
|
|
34
35
|
const dependencies = extractDependenciesFromError(errorMessage);
|
|
35
36
|
if (dependencies.length > 0) {
|
|
36
|
-
console.log(`⚠ ${pluginName} requires dependencies: ${dependencies.join(
|
|
37
|
+
console.log(`⚠ ${pluginName} requires dependencies: ${dependencies.join(", ")}`);
|
|
37
38
|
// Add dependencies to the remaining plugins list if they're not already there
|
|
38
39
|
for (const dep of dependencies) {
|
|
39
|
-
if (!pluginsToActivate.includes(dep) &&
|
|
40
|
+
if (!pluginsToActivate.includes(dep) &&
|
|
41
|
+
!excludedPlugins.includes(dep)) {
|
|
40
42
|
pluginsToActivate.push(dep);
|
|
41
43
|
}
|
|
42
44
|
if (!remainingPlugins.includes(dep)) {
|
|
@@ -54,7 +56,7 @@ async function activatePluginsWithRetry(execute, pluginsToActivate, excludedPlug
|
|
|
54
56
|
retryCount++;
|
|
55
57
|
}
|
|
56
58
|
if (remainingPlugins.length > 0) {
|
|
57
|
-
console.warn(`⚠ Warning: Could not activate all plugins after ${maxRetries} attempts. Remaining: ${remainingPlugins.join(
|
|
59
|
+
console.warn(`⚠ Warning: Could not activate all plugins after ${maxRetries} attempts. Remaining: ${remainingPlugins.join(", ")}`);
|
|
58
60
|
}
|
|
59
61
|
}
|
|
60
62
|
export const command = "setup-database";
|
|
@@ -89,14 +91,19 @@ export async function handler() {
|
|
|
89
91
|
performance.mark("add-custom-user");
|
|
90
92
|
console.log(`Custom user ${process.env.WORDPRESS_USER} added. (${convertMeasureToPrettyString(performance.measure("add-custom-user", "wordpress-tables"))})`);
|
|
91
93
|
}
|
|
92
|
-
const excludedPlugins = [
|
|
93
|
-
|
|
94
|
+
const excludedPlugins = [
|
|
95
|
+
"stream",
|
|
96
|
+
"shortpixel-image-optimiser",
|
|
97
|
+
"wordfence",
|
|
98
|
+
"wp-mail-smtp",
|
|
99
|
+
];
|
|
100
|
+
const { stdout: pluginList } = await execute("wp plugin list --format=json");
|
|
94
101
|
const allPlugins = JSON.parse(pluginList);
|
|
95
102
|
// Filter out excluded plugins and already active plugins
|
|
96
103
|
const pluginsToActivate = allPlugins
|
|
97
|
-
.filter(plugin => !excludedPlugins.includes(plugin.name) &&
|
|
98
|
-
plugin.status !==
|
|
99
|
-
.map(plugin => plugin.name);
|
|
104
|
+
.filter((plugin) => !excludedPlugins.includes(plugin.name) &&
|
|
105
|
+
plugin.status !== "active")
|
|
106
|
+
.map((plugin) => plugin.name);
|
|
100
107
|
await activatePluginsWithRetry(execute, pluginsToActivate, excludedPlugins);
|
|
101
108
|
})
|
|
102
109
|
.then(() => {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"setup.d.ts","sourceRoot":"","sources":["../../src/commands/setup.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"setup.d.ts","sourceRoot":"","sources":["../../src/commands/setup.ts"],"names":[],"mappings":"AAcA,eAAO,MAAM,OAAO,UAAU,CAAC;AAC/B,eAAO,MAAM,QAAQ,kDAAkD,CAAC;AACxE,wBAAsB,OAAO,kBAsQ5B"}
|
package/dist/commands/setup.js
CHANGED
|
@@ -4,7 +4,8 @@ import { constants, copyFile, unlink as deleteFile, mkdir, } from "node:fs/promi
|
|
|
4
4
|
import { resolve } from "node:path";
|
|
5
5
|
import { performance } from "node:perf_hooks";
|
|
6
6
|
import { promisify } from "node:util";
|
|
7
|
-
import {
|
|
7
|
+
import { getSmashConfig } from "@atomicsmash/smash-config";
|
|
8
|
+
import { convertMeasureToPrettyString, startRunningMessage } from "../utils.js";
|
|
8
9
|
export const command = "setup";
|
|
9
10
|
export const describe = "Run all the common setup tasks for a project.";
|
|
10
11
|
export async function handler() {
|
|
@@ -17,6 +18,7 @@ export async function handler() {
|
|
|
17
18
|
.catch(() => {
|
|
18
19
|
return false;
|
|
19
20
|
});
|
|
21
|
+
const isCI = process.env.CI ?? false;
|
|
20
22
|
const smashConfig = await getSmashConfig();
|
|
21
23
|
if (!smashConfig) {
|
|
22
24
|
throw new Error("Unable to determine project setup information. Please add a smash.config.ts file with the required info.");
|
|
@@ -26,7 +28,7 @@ export async function handler() {
|
|
|
26
28
|
const stopRunningMessage = startRunningMessage("Running setup");
|
|
27
29
|
performance.mark("Start");
|
|
28
30
|
await Promise.allSettled([
|
|
29
|
-
...(shouldInstallAndBuildOnly
|
|
31
|
+
...(isCI || shouldInstallAndBuildOnly
|
|
30
32
|
? []
|
|
31
33
|
: [
|
|
32
34
|
(async () => {
|
|
@@ -110,7 +112,7 @@ export async function handler() {
|
|
|
110
112
|
}
|
|
111
113
|
})(),
|
|
112
114
|
]),
|
|
113
|
-
execute(
|
|
115
|
+
execute(`composer install${isCI ? " --prefer-dist" : ""}`)
|
|
114
116
|
.then(() => {
|
|
115
117
|
console.log(`Root composer install done. (${convertMeasureToPrettyString(performance.measure("root composer install", "Start"))})`);
|
|
116
118
|
})
|
|
@@ -119,7 +121,7 @@ export async function handler() {
|
|
|
119
121
|
throw new Error("Failed to run composer install in the root directory.");
|
|
120
122
|
}),
|
|
121
123
|
...(composerInstallPaths?.map((path, index) => {
|
|
122
|
-
return execute(`cd "${resolve(process.cwd(), path)}"; composer install`)
|
|
124
|
+
return execute(`cd "${resolve(process.cwd(), path)}"; composer install${isCI ? " --no-dev --classmap-authoritative" : ""}`)
|
|
123
125
|
.then(() => {
|
|
124
126
|
console.log(`Additional composer install ${index + 1} done. (${convertMeasureToPrettyString(performance.measure(`additional composer install ${index + 1}`, "Start"))})`);
|
|
125
127
|
})
|
|
@@ -129,7 +131,7 @@ export async function handler() {
|
|
|
129
131
|
});
|
|
130
132
|
}) ?? []),
|
|
131
133
|
(async () => {
|
|
132
|
-
await execute(
|
|
134
|
+
await execute(`npm ${isCI ? "ci" : "install"}`)
|
|
133
135
|
.then(() => {
|
|
134
136
|
performance.mark("root npm install done");
|
|
135
137
|
console.log(`Root npm install done. (${convertMeasureToPrettyString(performance.measure("root npm install", "Start"))})`);
|
|
@@ -150,7 +152,7 @@ export async function handler() {
|
|
|
150
152
|
throw new Error(reason);
|
|
151
153
|
}),
|
|
152
154
|
...(npmInstallPaths?.map((path, index) => {
|
|
153
|
-
return execute(`cd "${resolve(process.cwd(), path)}"; npm install`)
|
|
155
|
+
return execute(`cd "${resolve(process.cwd(), path)}"; npm ${isCI ? "ci --omit=dev" : "install"}`)
|
|
154
156
|
.then(() => {
|
|
155
157
|
console.log(`Additional npm install ${index + 1} done. (${convertMeasureToPrettyString(performance.measure(`additional npm install ${index + 1}`, "Start"))})`);
|
|
156
158
|
})
|
|
@@ -159,7 +161,8 @@ export async function handler() {
|
|
|
159
161
|
throw new Error(`Failed to run additional npm install ${index + 1}.`);
|
|
160
162
|
});
|
|
161
163
|
}) ?? []),
|
|
162
|
-
])
|
|
164
|
+
])
|
|
165
|
+
.then(async (results) => {
|
|
163
166
|
await stopRunningMessage();
|
|
164
167
|
if (results.some((result) => result.status === "rejected")) {
|
|
165
168
|
process.exitCode = 1;
|
|
@@ -174,7 +177,8 @@ export async function handler() {
|
|
|
174
177
|
else {
|
|
175
178
|
console.log(`Setup is complete. ${convertMeasureToPrettyString(performance.measure("everything", "Start"))}`);
|
|
176
179
|
}
|
|
177
|
-
})
|
|
180
|
+
})
|
|
181
|
+
.catch((error) => {
|
|
178
182
|
console.error(error);
|
|
179
183
|
process.exitCode = 1;
|
|
180
184
|
});
|
package/dist/index.d.ts
CHANGED
|
@@ -1,16 +1,2 @@
|
|
|
1
|
-
|
|
2
|
-
export type SCSSAliases = {
|
|
3
|
-
loadPaths?: Options<"async">["loadPaths"];
|
|
4
|
-
importers?: Options<"async">["importers"];
|
|
5
|
-
};
|
|
6
|
-
export type SmashConfig = {
|
|
7
|
-
projectName: string;
|
|
8
|
-
themePath: string;
|
|
9
|
-
themeFolderName?: string;
|
|
10
|
-
assetsOutputFolder?: string;
|
|
11
|
-
npmInstallPaths?: string[];
|
|
12
|
-
composerInstallPaths?: string[];
|
|
13
|
-
scssAliases?: SCSSAliases;
|
|
14
|
-
};
|
|
15
|
-
export { getSmashConfig } from "./utils.js";
|
|
1
|
+
export {};
|
|
16
2
|
//# sourceMappingURL=index.d.ts.map
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":""}
|
package/dist/index.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export {
|
|
1
|
+
export {};
|
package/dist/utils.d.ts
CHANGED
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import type { SCSSAliases, SmashConfig } from "./index.js";
|
|
2
1
|
import type { ExecException } from "node:child_process";
|
|
3
2
|
import type { PerformanceMeasure } from "node:perf_hooks";
|
|
4
3
|
import type { PackageJson } from "type-fest";
|
|
@@ -15,13 +14,4 @@ export declare function execute(command: string, options?: {
|
|
|
15
14
|
export declare function toCamelCase(text: string): string;
|
|
16
15
|
export declare function convertMeasureToPrettyString(measure: PerformanceMeasure): string;
|
|
17
16
|
export declare function startRunningMessage(message: string): () => Promise<void>;
|
|
18
|
-
export declare function getSmashConfig(): Promise<Required<SmashConfig> | {
|
|
19
|
-
npmInstallPaths: string[];
|
|
20
|
-
composerInstallPaths: string[];
|
|
21
|
-
assetsOutputFolder: string;
|
|
22
|
-
projectName: string;
|
|
23
|
-
themePath: string;
|
|
24
|
-
themeFolderName: string;
|
|
25
|
-
scssAliases: SCSSAliases;
|
|
26
|
-
} | null>;
|
|
27
17
|
//# sourceMappingURL=utils.d.ts.map
|
package/dist/utils.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../src/utils.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,
|
|
1
|
+
{"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../src/utils.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,oBAAoB,CAAC;AACxD,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,iBAAiB,CAAC;AAC1D,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,WAAW,CAAC;AAM7C,eAAO,MAAM,WAAW,EAAiC,WAAW,CAAC;AAIrE,eAAO,MAAM,WAAW,QAA6D,CAAC;AAItF,eAAO,MAAM,cAAc,QAAsB,CAAC;AAElD,wBAAsB,OAAO,CAC5B,OAAO,EAAE,MAAM,EACf,OAAO,GAAE;IAAE,KAAK,EAAE,OAAO,CAAA;CAAqB;WAGtC,aAAa,GAAG,IAAI;YACnB,MAAM;YACN,MAAM;GAaf;AAED,wBAAgB,WAAW,CAAC,IAAI,EAAE,MAAM,UAQvC;AAED,wBAAgB,4BAA4B,CAAC,OAAO,EAAE,kBAAkB,UAevE;AAED,wBAAgB,mBAAmB,CAAC,OAAO,EAAE,MAAM,uBAiClD"}
|
package/dist/utils.js
CHANGED
|
@@ -1,8 +1,6 @@
|
|
|
1
1
|
import { exec } from "node:child_process";
|
|
2
2
|
import { createRequire } from "node:module";
|
|
3
|
-
import {
|
|
4
|
-
import { pathToFileURL } from "node:url";
|
|
5
|
-
import { cosmiconfig } from "cosmiconfig";
|
|
3
|
+
import { resolve } from "node:path";
|
|
6
4
|
const require = createRequire(import.meta.url);
|
|
7
5
|
export const packageJson = require("../package.json");
|
|
8
6
|
if (packageJson.bin === undefined) {
|
|
@@ -84,93 +82,3 @@ export function startRunningMessage(message) {
|
|
|
84
82
|
/* do nothing */
|
|
85
83
|
};
|
|
86
84
|
}
|
|
87
|
-
const getDefaultSCSSAliases = (themePath) => ({
|
|
88
|
-
importers: [
|
|
89
|
-
{
|
|
90
|
-
findFileUrl(url) {
|
|
91
|
-
if (!url.startsWith("sitecss:"))
|
|
92
|
-
return null;
|
|
93
|
-
const pathname = url.substring(8);
|
|
94
|
-
return pathToFileURL(`${resolve(process.cwd(), themePath, "src/styles")}${pathname.startsWith("/") ? pathname : `/${pathname}`}`);
|
|
95
|
-
},
|
|
96
|
-
},
|
|
97
|
-
{
|
|
98
|
-
findFileUrl(url) {
|
|
99
|
-
if (!url.startsWith("launchpad:"))
|
|
100
|
-
return null;
|
|
101
|
-
const pathname = url.substring(10);
|
|
102
|
-
return pathToFileURL(`${resolve(process.cwd(), themePath, "../launchpad/src/styles")}${pathname.startsWith("/") ? pathname : `/${pathname}`}`);
|
|
103
|
-
},
|
|
104
|
-
},
|
|
105
|
-
],
|
|
106
|
-
});
|
|
107
|
-
export async function getSmashConfig() {
|
|
108
|
-
const explorer = cosmiconfig("smash");
|
|
109
|
-
const config = await explorer
|
|
110
|
-
.load(resolve(process.cwd(), "smash.config.ts"))
|
|
111
|
-
.then((result) => {
|
|
112
|
-
if (!result || result.isEmpty) {
|
|
113
|
-
throw new Error("Return default config.");
|
|
114
|
-
}
|
|
115
|
-
const config = result.config;
|
|
116
|
-
if (isValidSmashConfig(config)) {
|
|
117
|
-
return {
|
|
118
|
-
scssAliases: getDefaultSCSSAliases(config.themePath),
|
|
119
|
-
themeFolderName: config.projectName,
|
|
120
|
-
...config,
|
|
121
|
-
// Normalize and resolve paths to cwd.
|
|
122
|
-
npmInstallPaths: config.npmInstallPaths?.map((path) => {
|
|
123
|
-
return normalize(resolve(process.cwd(), path));
|
|
124
|
-
}) ?? [],
|
|
125
|
-
composerInstallPaths: config.composerInstallPaths?.map((path) => {
|
|
126
|
-
return normalize(resolve(process.cwd(), path));
|
|
127
|
-
}) ?? [],
|
|
128
|
-
assetsOutputFolder: config.assetsOutputFolder
|
|
129
|
-
? normalize(config.assetsOutputFolder)
|
|
130
|
-
: "dist",
|
|
131
|
-
};
|
|
132
|
-
}
|
|
133
|
-
throw new Error("Return default config.");
|
|
134
|
-
})
|
|
135
|
-
.catch(async () => {
|
|
136
|
-
const { themeName, themePath } = await import("dotenv")
|
|
137
|
-
.then((dotenv) => {
|
|
138
|
-
dotenv.config();
|
|
139
|
-
const themeName = process.env.THEME_NAME ?? process.env.npm_package_config_theme_name;
|
|
140
|
-
const themePath = process.env.THEME_PATH ?? process.env.npm_package_config_theme_path;
|
|
141
|
-
return {
|
|
142
|
-
themeName,
|
|
143
|
-
themePath,
|
|
144
|
-
};
|
|
145
|
-
})
|
|
146
|
-
.catch(() => {
|
|
147
|
-
return {
|
|
148
|
-
themeName: false,
|
|
149
|
-
themePath: false,
|
|
150
|
-
};
|
|
151
|
-
});
|
|
152
|
-
if (!themeName || !themePath) {
|
|
153
|
-
return null;
|
|
154
|
-
}
|
|
155
|
-
console.warn("Using env vars for theme name and path is deprecated and will be removed in a future version. Create a smash.config.ts file with the relevant properties in it instead.");
|
|
156
|
-
const defaultConfig = {
|
|
157
|
-
projectName: themeName,
|
|
158
|
-
themePath,
|
|
159
|
-
themeFolderName: themeName,
|
|
160
|
-
assetsOutputFolder: "dist",
|
|
161
|
-
npmInstallPaths: [],
|
|
162
|
-
composerInstallPaths: [],
|
|
163
|
-
scssAliases: getDefaultSCSSAliases(themePath),
|
|
164
|
-
};
|
|
165
|
-
return defaultConfig;
|
|
166
|
-
});
|
|
167
|
-
return config;
|
|
168
|
-
}
|
|
169
|
-
function isValidSmashConfig(config) {
|
|
170
|
-
return (typeof config === "object" &&
|
|
171
|
-
config !== null &&
|
|
172
|
-
"projectName" in config &&
|
|
173
|
-
typeof config.projectName === "string" &&
|
|
174
|
-
"themePath" in config &&
|
|
175
|
-
typeof config.themePath === "string");
|
|
176
|
-
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@atomicsmash/cli",
|
|
3
|
-
"version": "10.0.0-beta.
|
|
3
|
+
"version": "10.0.0-beta.2",
|
|
4
4
|
"description": "A collection of CLI tools by Atomic Smash.",
|
|
5
5
|
"keywords": [],
|
|
6
6
|
"homepage": "https://www.atomicsmash.co.uk/",
|
|
@@ -41,6 +41,7 @@
|
|
|
41
41
|
},
|
|
42
42
|
"dependencies": {
|
|
43
43
|
"@atomicsmash/date-php": "^2.1.0",
|
|
44
|
+
"@atomicsmash/smash-config": "^1.0.0-beta.0",
|
|
44
45
|
"@types/vinyl": "^2.0.12",
|
|
45
46
|
"cosmiconfig": "^9.0.0",
|
|
46
47
|
"glob-promise": "^6.0.7",
|