@atomicsmash/cli 8.2.0-beta.2 → 8.2.0-beta.4
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/blocks.d.ts.map +1 -1
- package/dist/commands/blocks.js +4 -2
- package/dist/commands/pull-database.d.ts.map +1 -1
- package/dist/commands/pull-database.js +31 -14
- package/dist/commands/pull-media.d.ts.map +1 -1
- package/dist/commands/pull-media.js +5 -9
- package/dist/commands/setup-database.d.ts +1 -1
- package/dist/commands/setup-database.d.ts.map +1 -1
- package/dist/commands/setup-database.js +6 -10
- package/dist/commands/setup.d.ts.map +1 -1
- package/dist/commands/setup.js +3 -5
- package/dist/utils.d.ts +1 -1
- package/dist/utils.d.ts.map +1 -1
- package/dist/utils.js +19 -2
- package/package.json +1 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"blocks.d.ts","sourceRoot":"","sources":["../../src/commands/blocks.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,WAAW,CAAC;AAE/C,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,6BAA6B,CAAC;AAIjE,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,OAAO,CAAC;AAwBhD,OAAO,OAAO,MAAM,SAAS,CAAC;AAM9B,eAAO,MAAM,OAAO,WAAW,CAAC;AAChC,eAAO,MAAM,QAAQ,8DACuC,CAAC;AAC7D,eAAO,MAAM,OAAO,GAAa,OAAO,aAAa;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;iBA0ClC,MAAM,EAAE;;;;;;;;;;;;;GAqB1B,CAAC;AAEF,wBAAsB,OAAO,CAC5B,IAAI,EAAE,kBAAkB,CAAC,OAAO,CAAC,UAAU,CAAC,OAAO,OAAO,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,iBA4CrE;
|
|
1
|
+
{"version":3,"file":"blocks.d.ts","sourceRoot":"","sources":["../../src/commands/blocks.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|
package/dist/commands/blocks.js
CHANGED
|
@@ -16,7 +16,7 @@ import { TsconfigPathsPlugin } from "tsconfig-paths-webpack-plugin";
|
|
|
16
16
|
import { tsImport } from "tsx/esm/api";
|
|
17
17
|
import webpack from "webpack";
|
|
18
18
|
import defaultConfig from "../external/wordpress.webpack.config.cjs";
|
|
19
|
-
import { getSmashConfig, toCamelCase } from "../utils.js";
|
|
19
|
+
import { getSmashConfig, startRunningMessage, toCamelCase } from "../utils.js";
|
|
20
20
|
const isProduction = process.env.NODE_ENV === "production";
|
|
21
21
|
export const command = "blocks";
|
|
22
22
|
export const describe = "A command to generate WordPress blocks from a src folder.";
|
|
@@ -194,7 +194,9 @@ async function runCommand({ srcFolder, distFolder, tsConfigLocation, postcssConf
|
|
|
194
194
|
});
|
|
195
195
|
}
|
|
196
196
|
else {
|
|
197
|
-
|
|
197
|
+
const stopRunningMessage = startRunningMessage("Building blocks");
|
|
198
|
+
compiler.run(async (error, stats) => {
|
|
199
|
+
await stopRunningMessage();
|
|
198
200
|
if (error) {
|
|
199
201
|
console.error(error);
|
|
200
202
|
process.exitCode = 1;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"pull-database.d.ts","sourceRoot":"","sources":["../../src/commands/pull-database.ts"],"names":[],"mappings":"AAYA,eAAO,MAAM,OAAO,kBAAkB,CAAC;AACvC,eAAO,MAAM,QAAQ,oEAC6C,CAAC;AACnE,wBAAsB,OAAO,
|
|
1
|
+
{"version":3,"file":"pull-database.d.ts","sourceRoot":"","sources":["../../src/commands/pull-database.ts"],"names":[],"mappings":"AAYA,eAAO,MAAM,OAAO,kBAAkB,CAAC;AACvC,eAAO,MAAM,QAAQ,oEAC6C,CAAC;AACnE,wBAAsB,OAAO,kBAqH5B"}
|
|
@@ -33,15 +33,17 @@ export async function handler() {
|
|
|
33
33
|
}
|
|
34
34
|
else {
|
|
35
35
|
const { themeName } = smashConfig;
|
|
36
|
-
const
|
|
36
|
+
const stopRunningMessage = startRunningMessage("Pulling database from staging");
|
|
37
37
|
performance.mark("Start");
|
|
38
38
|
await (async () => {
|
|
39
39
|
const tmpFile = "/tmp/staging-database.sql";
|
|
40
40
|
const tmpFileProcessed = "/tmp/staging-database.processed.sql";
|
|
41
41
|
await execute(`ssh ${stagingSSHUsername}@${stagingSSHHost} -p ${stagingSSHPort} "cd public/current && wp db export - --add-drop-table" > ${tmpFile}`)
|
|
42
|
-
.then(() => {
|
|
43
|
-
|
|
44
|
-
|
|
42
|
+
.then(async () => {
|
|
43
|
+
await stopRunningMessage();
|
|
44
|
+
console.log("Database downloaded.");
|
|
45
|
+
const stopRunningMessage2 = startRunningMessage("Updating URLs in database SQL");
|
|
46
|
+
await new Promise((resolve, reject) => {
|
|
45
47
|
const readStream = createReadStream(tmpFile, { encoding: "utf8" });
|
|
46
48
|
const writeStream = createWriteStream(tmpFileProcessed, {
|
|
47
49
|
encoding: "utf8",
|
|
@@ -56,23 +58,38 @@ export async function handler() {
|
|
|
56
58
|
writeStream.on("finish", resolve);
|
|
57
59
|
writeStream.on("error", reject);
|
|
58
60
|
readStream.on("error", reject);
|
|
61
|
+
})
|
|
62
|
+
.then(async () => {
|
|
63
|
+
await stopRunningMessage2();
|
|
64
|
+
console.log("URLs updated.");
|
|
65
|
+
})
|
|
66
|
+
.catch(async (error) => {
|
|
67
|
+
await stopRunningMessage2();
|
|
68
|
+
throw error;
|
|
59
69
|
});
|
|
60
70
|
})
|
|
61
71
|
.then(async () => {
|
|
62
|
-
|
|
63
|
-
await execute(`wp db query < ${tmpFileProcessed}`)
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
72
|
+
const stopRunningMessage3 = startRunningMessage("Importing database");
|
|
73
|
+
await execute(`wp db query < ${tmpFileProcessed}`)
|
|
74
|
+
.then(async () => {
|
|
75
|
+
await stopRunningMessage3();
|
|
76
|
+
})
|
|
77
|
+
.catch(async (error) => {
|
|
78
|
+
await stopRunningMessage3();
|
|
79
|
+
throw error;
|
|
80
|
+
});
|
|
81
|
+
const stopRunningMessage4 = startRunningMessage("Cleaning up");
|
|
82
|
+
await Promise.allSettled([
|
|
83
|
+
deleteFile(tmpFile),
|
|
84
|
+
deleteFile(tmpFileProcessed),
|
|
85
|
+
]).then(async () => {
|
|
86
|
+
await stopRunningMessage4();
|
|
87
|
+
});
|
|
69
88
|
console.log(`Database import complete! ${convertMeasureToPrettyString(performance.measure("everything", "Start"))}`);
|
|
70
89
|
console.log("If you want to download recent media you can use `npm run pull:media`, you can also change the number of months to download in your `.env` file.");
|
|
71
90
|
})
|
|
72
91
|
.catch(async (error) => {
|
|
73
|
-
|
|
74
|
-
clearInterval(interval);
|
|
75
|
-
}
|
|
92
|
+
await stopRunningMessage();
|
|
76
93
|
console.error("Error during database pull:", error);
|
|
77
94
|
const cleanupResults = await Promise.allSettled([
|
|
78
95
|
deleteFile(tmpFile),
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"pull-media.d.ts","sourceRoot":"","sources":["../../src/commands/pull-media.ts"],"names":[],"mappings":"AAmCA,eAAO,MAAM,OAAO,eAAe,CAAC;AACpC,eAAO,MAAM,QAAQ,gDAAgD,CAAC;AACtE,wBAAsB,OAAO,
|
|
1
|
+
{"version":3,"file":"pull-media.d.ts","sourceRoot":"","sources":["../../src/commands/pull-media.ts"],"names":[],"mappings":"AAmCA,eAAO,MAAM,OAAO,eAAe,CAAC;AACpC,eAAO,MAAM,QAAQ,gDAAgD,CAAC;AACtE,wBAAsB,OAAO,kBA4E5B"}
|
|
@@ -56,7 +56,7 @@ export async function handler() {
|
|
|
56
56
|
host: stagingSSHHost,
|
|
57
57
|
username: stagingSSHUsername,
|
|
58
58
|
};
|
|
59
|
-
const
|
|
59
|
+
const stopRunningMessage = startRunningMessage("Pulling media from staging");
|
|
60
60
|
performance.mark("Start");
|
|
61
61
|
await (async () => {
|
|
62
62
|
if (mediaMonths === -1) {
|
|
@@ -87,16 +87,12 @@ export async function handler() {
|
|
|
87
87
|
console.log("Finished attempting to download all requested months");
|
|
88
88
|
}
|
|
89
89
|
})()
|
|
90
|
-
.then(() => {
|
|
91
|
-
|
|
92
|
-
clearInterval(interval);
|
|
93
|
-
}
|
|
90
|
+
.then(async () => {
|
|
91
|
+
await stopRunningMessage();
|
|
94
92
|
console.log("Media download complete!");
|
|
95
93
|
})
|
|
96
|
-
.catch(() => {
|
|
97
|
-
|
|
98
|
-
clearInterval(interval);
|
|
99
|
-
}
|
|
94
|
+
.catch(async () => {
|
|
95
|
+
await stopRunningMessage();
|
|
100
96
|
console.log("There was an error downloading the media, see the message above.");
|
|
101
97
|
});
|
|
102
98
|
}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import "dotenv/config";
|
|
2
2
|
export declare const command = "setup-database";
|
|
3
3
|
export declare const describe = "Create a new database and initialise the site with no content.";
|
|
4
|
-
export
|
|
4
|
+
export declare function handler(): Promise<void>;
|
|
5
5
|
//# sourceMappingURL=setup-database.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"setup-database.d.ts","sourceRoot":"","sources":["../../src/commands/setup-database.ts"],"names":[],"mappings":"AAQA,OAAO,eAAe,CAAC;AAEvB,eAAO,MAAM,OAAO,mBAAmB,CAAC;AACxC,eAAO,MAAM,QAAQ,mEAC4C,CAAC;AAClE,
|
|
1
|
+
{"version":3,"file":"setup-database.d.ts","sourceRoot":"","sources":["../../src/commands/setup-database.ts"],"names":[],"mappings":"AAQA,OAAO,eAAe,CAAC;AAEvB,eAAO,MAAM,OAAO,mBAAmB,CAAC;AACxC,eAAO,MAAM,QAAQ,mEAC4C,CAAC;AAClE,wBAAsB,OAAO,kBAsF5B"}
|
|
@@ -5,7 +5,7 @@ import { convertMeasureToPrettyString, getSmashConfig, startRunningMessage, } fr
|
|
|
5
5
|
import "dotenv/config";
|
|
6
6
|
export const command = "setup-database";
|
|
7
7
|
export const describe = "Create a new database and initialise the site with no content.";
|
|
8
|
-
export
|
|
8
|
+
export async function handler() {
|
|
9
9
|
const execute = promisify(exec);
|
|
10
10
|
const smashConfig = await getSmashConfig();
|
|
11
11
|
// These must remain env vars because they differ for each dev.
|
|
@@ -17,7 +17,7 @@ export default async function setupDatabase() {
|
|
|
17
17
|
}
|
|
18
18
|
else {
|
|
19
19
|
const { themeName } = smashConfig;
|
|
20
|
-
const
|
|
20
|
+
const stopRunningMessage = startRunningMessage("Initialising database");
|
|
21
21
|
performance.mark("Start");
|
|
22
22
|
await execute("wp db create")
|
|
23
23
|
.then(() => {
|
|
@@ -42,18 +42,14 @@ export default async function setupDatabase() {
|
|
|
42
42
|
console.log(`Plugins activated. (${convertMeasureToPrettyString(performance.measure("plugins", addCustomUser ? "add-custom-user" : "wordpress-tables"))})`);
|
|
43
43
|
return execute(`wp theme activate ${themeName}`);
|
|
44
44
|
})
|
|
45
|
-
.then(() => {
|
|
45
|
+
.then(async () => {
|
|
46
46
|
performance.mark("theme");
|
|
47
47
|
console.log(`Theme activated. (${convertMeasureToPrettyString(performance.measure("theme", "plugins"))})`);
|
|
48
|
-
|
|
49
|
-
clearInterval(interval);
|
|
50
|
-
}
|
|
48
|
+
await stopRunningMessage();
|
|
51
49
|
console.log(`Database set up${addCustomUser ? ` and ${process.env.WORDPRESS_USER} user added` : !process.env.CI ? ". To set up a user, run the `wp user create` command." : ""}. (${convertMeasureToPrettyString(performance.measure("everything", "Start"))})`);
|
|
52
50
|
})
|
|
53
|
-
.catch((error) => {
|
|
54
|
-
|
|
55
|
-
clearInterval(interval);
|
|
56
|
-
}
|
|
51
|
+
.catch(async (error) => {
|
|
52
|
+
await stopRunningMessage();
|
|
57
53
|
if (error.stderr?.startsWith("ERROR 1007")) {
|
|
58
54
|
console.error("Database already exists with the name in the wp-config. Please delete that database first with `wp db drop --yes`");
|
|
59
55
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"setup.d.ts","sourceRoot":"","sources":["../../src/commands/setup.ts"],"names":[],"mappings":"AAYA,eAAO,MAAM,OAAO,UAAU,CAAC;AAC/B,eAAO,MAAM,QAAQ,kDAAkD,CAAC;AACxE,wBAAsB,OAAO,
|
|
1
|
+
{"version":3,"file":"setup.d.ts","sourceRoot":"","sources":["../../src/commands/setup.ts"],"names":[],"mappings":"AAYA,eAAO,MAAM,OAAO,UAAU,CAAC;AAC/B,eAAO,MAAM,QAAQ,kDAAkD,CAAC;AACxE,wBAAsB,OAAO,kBAiM5B"}
|
package/dist/commands/setup.js
CHANGED
|
@@ -23,7 +23,7 @@ export async function handler() {
|
|
|
23
23
|
}
|
|
24
24
|
else {
|
|
25
25
|
const { themeName, composerInstallPaths, npmInstallPaths } = smashConfig;
|
|
26
|
-
const
|
|
26
|
+
const stopRunningMessage = startRunningMessage("Running setup");
|
|
27
27
|
performance.mark("Start");
|
|
28
28
|
await Promise.allSettled([
|
|
29
29
|
...(shouldInstallAndBuildOnly
|
|
@@ -123,10 +123,8 @@ export async function handler() {
|
|
|
123
123
|
throw new Error(`Failed to run additional npm install ${index + 1}.`);
|
|
124
124
|
});
|
|
125
125
|
}) ?? []),
|
|
126
|
-
]).then((results) => {
|
|
127
|
-
|
|
128
|
-
clearInterval(interval);
|
|
129
|
-
}
|
|
126
|
+
]).then(async (results) => {
|
|
127
|
+
await stopRunningMessage();
|
|
130
128
|
if (results.some((result) => result.status === "rejected")) {
|
|
131
129
|
process.exitCode = 1;
|
|
132
130
|
console.error("Setup failed with the following errors:\n");
|
package/dist/utils.d.ts
CHANGED
|
@@ -14,7 +14,7 @@ export declare function execute(command: string, options?: {
|
|
|
14
14
|
}>;
|
|
15
15
|
export declare function toCamelCase(text: string): string;
|
|
16
16
|
export declare function convertMeasureToPrettyString(measure: PerformanceMeasure): string;
|
|
17
|
-
export declare function startRunningMessage(message: string):
|
|
17
|
+
export declare function startRunningMessage(message: string): () => Promise<void>;
|
|
18
18
|
export declare function getSmashConfig(): Promise<Required<SmashConfig> | {
|
|
19
19
|
npmInstallPaths: string[];
|
|
20
20
|
composerInstallPaths: string[];
|
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,WAAW,EAAE,WAAW,EAAE,MAAM,YAAY,CAAC;AAC3D,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;AAQ7C,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,
|
|
1
|
+
{"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../src/utils.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,WAAW,EAAE,MAAM,YAAY,CAAC;AAC3D,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;AAQ7C,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;AAyBD,wBAAsB,cAAc;;;;;;;UAiEnC"}
|
package/dist/utils.js
CHANGED
|
@@ -55,7 +55,7 @@ export function startRunningMessage(message) {
|
|
|
55
55
|
process.stdout.write(`${message}${".".repeat($i)}\r`);
|
|
56
56
|
$i++;
|
|
57
57
|
if (typeof process.stdout.clearLine !== "undefined") {
|
|
58
|
-
|
|
58
|
+
const interval = setInterval(() => {
|
|
59
59
|
if ($i > 2) {
|
|
60
60
|
$i = 0;
|
|
61
61
|
}
|
|
@@ -64,8 +64,25 @@ export function startRunningMessage(message) {
|
|
|
64
64
|
process.stdout.cursorTo(0);
|
|
65
65
|
process.stdout.write(`${message}${".".repeat($i)}\r`);
|
|
66
66
|
}, 200);
|
|
67
|
+
return async () => {
|
|
68
|
+
if (interval) {
|
|
69
|
+
clearInterval(interval);
|
|
70
|
+
await new Promise((resolve) => {
|
|
71
|
+
process.stdout.clearLine(0, () => {
|
|
72
|
+
resolve();
|
|
73
|
+
});
|
|
74
|
+
});
|
|
75
|
+
await new Promise((resolve) => {
|
|
76
|
+
process.stdout.cursorTo(0, () => {
|
|
77
|
+
resolve();
|
|
78
|
+
});
|
|
79
|
+
});
|
|
80
|
+
}
|
|
81
|
+
};
|
|
67
82
|
}
|
|
68
|
-
return
|
|
83
|
+
return async () => {
|
|
84
|
+
/* do nothing */
|
|
85
|
+
};
|
|
69
86
|
}
|
|
70
87
|
const getDefaultSCSSAliases = (themePath) => ({
|
|
71
88
|
importers: [
|