@atomicsmash/cli 11.0.0-beta.3 → 11.0.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/dist/commands/pull-database.js +1 -1
- package/dist/commands/pull-media.d.ts.map +1 -1
- package/dist/commands/pull-media.js +4 -4
- package/dist/commands/setup-database.d.ts.map +1 -1
- package/dist/commands/setup-database.js +20 -10
- package/dist/commands/setup.d.ts.map +1 -1
- package/dist/commands/setup.js +13 -10
- package/dist/utils.d.ts.map +1 -1
- package/dist/utils.js +14 -16
- package/package.json +6 -5
|
@@ -126,7 +126,7 @@ export async function handler() {
|
|
|
126
126
|
]);
|
|
127
127
|
const failedCleanups = cleanupResults.filter((result) => result.status === "rejected");
|
|
128
128
|
if (failedCleanups.length > 0) {
|
|
129
|
-
console.warn(`Warning: Failed to delete ${failedCleanups.length} temporary file(s). You may need to clean them up manually.`);
|
|
129
|
+
console.warn(`Warning: Failed to delete ${failedCleanups.length.toString()} temporary file(s). You may need to clean them up manually.`);
|
|
130
130
|
}
|
|
131
131
|
process.exitCode = 1;
|
|
132
132
|
});
|
|
@@ -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,kBA+E5B"}
|
|
@@ -66,21 +66,21 @@ export async function handler() {
|
|
|
66
66
|
await downloadFiles(mediaPath, localPath, ssh);
|
|
67
67
|
}
|
|
68
68
|
else {
|
|
69
|
-
console.log(`Downloading media for the last ${mediaMonths} months...`);
|
|
69
|
+
console.log(`Downloading media for the last ${mediaMonths.toString()} months...`);
|
|
70
70
|
// Download media for each month
|
|
71
71
|
for (let i = 0; i < mediaMonths; i++) {
|
|
72
72
|
const date = new Date();
|
|
73
73
|
date.setMonth(date.getMonth() - i);
|
|
74
74
|
const year = date.getFullYear();
|
|
75
75
|
const month = String(date.getMonth() + 1).padStart(2, "0");
|
|
76
|
-
const remotePath = `${mediaPath}/${year}/${month}`;
|
|
77
|
-
const localPath = `${mediaLocalPath}/${year}`;
|
|
76
|
+
const remotePath = `${mediaPath}/${year.toString()}/${month}`;
|
|
77
|
+
const localPath = `${mediaLocalPath}/${year.toString()}`;
|
|
78
78
|
console.log(`Attempting to download: ${remotePath} -> ${localPath}`);
|
|
79
79
|
try {
|
|
80
80
|
await downloadFiles(remotePath, localPath, ssh);
|
|
81
81
|
}
|
|
82
82
|
catch {
|
|
83
|
-
console.log(`Skipping uploads/${year}/${month} - directory does not exist on remote server`);
|
|
83
|
+
console.log(`Skipping uploads/${year.toString()}/${month} - directory does not exist on remote server`);
|
|
84
84
|
return; // Skip to next iteration
|
|
85
85
|
}
|
|
86
86
|
}
|
|
@@ -1 +1 @@
|
|
|
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,
|
|
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,kBA6H5B"}
|
|
@@ -56,7 +56,7 @@ async function activatePluginsWithRetry(execute, pluginsToActivate, excludedPlug
|
|
|
56
56
|
retryCount++;
|
|
57
57
|
}
|
|
58
58
|
if (remainingPlugins.length > 0) {
|
|
59
|
-
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.toString()} attempts. Remaining: ${remainingPlugins.join(", ")}`);
|
|
60
60
|
}
|
|
61
61
|
}
|
|
62
62
|
export const command = "setup-database";
|
|
@@ -65,9 +65,15 @@ export async function handler() {
|
|
|
65
65
|
const execute = promisify(exec);
|
|
66
66
|
const smashConfig = await getSmashConfig();
|
|
67
67
|
// These must remain env vars because they differ for each dev.
|
|
68
|
-
const
|
|
68
|
+
const newUserToAdd = process.env.WORDPRESS_USER &&
|
|
69
69
|
process.env.WORDPRESS_USER_EMAIL &&
|
|
70
|
-
process.env.WORDPRESS_PASSWORD
|
|
70
|
+
process.env.WORDPRESS_PASSWORD
|
|
71
|
+
? {
|
|
72
|
+
user: process.env.WORDPRESS_USER,
|
|
73
|
+
email: process.env.WORDPRESS_USER_EMAIL,
|
|
74
|
+
password: process.env.WORDPRESS_PASSWORD,
|
|
75
|
+
}
|
|
76
|
+
: null;
|
|
71
77
|
if (!smashConfig) {
|
|
72
78
|
throw new Error("Unable to determine project setup information. Please add a smash.config.ts file with the required info.");
|
|
73
79
|
}
|
|
@@ -82,14 +88,14 @@ export async function handler() {
|
|
|
82
88
|
.then(() => {
|
|
83
89
|
performance.mark("wordpress-tables");
|
|
84
90
|
console.log(`Wordpress database tables installed. (${convertMeasureToPrettyString(performance.measure("wordpress-tables", "Start"))})`);
|
|
85
|
-
if (
|
|
86
|
-
return execute(`wp user create ${
|
|
91
|
+
if (newUserToAdd) {
|
|
92
|
+
return execute(`wp user create ${newUserToAdd.user} ${newUserToAdd.email} --user_pass=${newUserToAdd.password} --role=administrator`);
|
|
87
93
|
}
|
|
88
94
|
})
|
|
89
95
|
.then(async () => {
|
|
90
|
-
if (
|
|
96
|
+
if (newUserToAdd) {
|
|
91
97
|
performance.mark("add-custom-user");
|
|
92
|
-
console.log(`Custom user ${
|
|
98
|
+
console.log(`Custom user ${newUserToAdd.user} added. (${convertMeasureToPrettyString(performance.measure("add-custom-user", "wordpress-tables"))})`);
|
|
93
99
|
}
|
|
94
100
|
const excludedPlugins = [
|
|
95
101
|
"stream",
|
|
@@ -109,18 +115,22 @@ export async function handler() {
|
|
|
109
115
|
})
|
|
110
116
|
.then(() => {
|
|
111
117
|
performance.mark("plugins");
|
|
112
|
-
console.log(`Plugins activated. (${convertMeasureToPrettyString(performance.measure("plugins",
|
|
118
|
+
console.log(`Plugins activated. (${convertMeasureToPrettyString(performance.measure("plugins", newUserToAdd ? "add-custom-user" : "wordpress-tables"))})`);
|
|
113
119
|
return execute(`wp theme activate ${themeFolderName}`);
|
|
114
120
|
})
|
|
115
121
|
.then(async () => {
|
|
116
122
|
performance.mark("theme");
|
|
117
123
|
console.log(`Theme activated. (${convertMeasureToPrettyString(performance.measure("theme", "plugins"))})`);
|
|
118
124
|
await stopRunningMessage();
|
|
119
|
-
console.log(`Database set up${
|
|
125
|
+
console.log(`Database set up${newUserToAdd ? ` and ${newUserToAdd.user} user added` : !process.env.CI ? ". To set up a user, run the `wp user create` command." : ""}. (${convertMeasureToPrettyString(performance.measure("everything", "Start"))})`);
|
|
120
126
|
})
|
|
121
127
|
.catch(async (error) => {
|
|
122
128
|
await stopRunningMessage();
|
|
123
|
-
if (error
|
|
129
|
+
if (typeof error === "object" &&
|
|
130
|
+
error &&
|
|
131
|
+
"stderr" in error &&
|
|
132
|
+
typeof error.stderr === "string" &&
|
|
133
|
+
error.stderr.startsWith("ERROR 1007")) {
|
|
124
134
|
console.error("Database already exists with the name in the wp-config. Please delete that database first with `wp db drop --yes`");
|
|
125
135
|
}
|
|
126
136
|
else {
|
|
@@ -1 +1 @@
|
|
|
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,
|
|
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,kBAoQ5B"}
|
package/dist/commands/setup.js
CHANGED
|
@@ -117,16 +117,16 @@ export async function handler() {
|
|
|
117
117
|
console.error(error);
|
|
118
118
|
throw new Error("Failed to run composer install in the root directory.");
|
|
119
119
|
}),
|
|
120
|
-
...
|
|
120
|
+
...composerInstallPaths.map((path, index) => {
|
|
121
121
|
return execute(`cd "${resolve(process.cwd(), path)}"; composer install${isCI ? " --no-dev --classmap-authoritative" : ""}`)
|
|
122
122
|
.then(() => {
|
|
123
|
-
console.log(`Additional composer install ${index + 1} done. (${convertMeasureToPrettyString(performance.measure(`additional composer install ${index + 1}`, "Start"))})`);
|
|
123
|
+
console.log(`Additional composer install ${(index + 1).toString()} done. (${convertMeasureToPrettyString(performance.measure(`additional composer install ${(index + 1).toString()}`, "Start"))})`);
|
|
124
124
|
})
|
|
125
125
|
.catch((error) => {
|
|
126
126
|
console.error(error);
|
|
127
|
-
throw new Error(`Failed to run additional composer install ${index + 1}.`);
|
|
127
|
+
throw new Error(`Failed to run additional composer install ${(index + 1).toString()}.`);
|
|
128
128
|
});
|
|
129
|
-
})
|
|
129
|
+
}),
|
|
130
130
|
(async () => {
|
|
131
131
|
await execute(`npm ${isCI ? "ci" : "install"}`)
|
|
132
132
|
.then(() => {
|
|
@@ -146,18 +146,21 @@ export async function handler() {
|
|
|
146
146
|
throw new Error("Failed to run a build after installing.");
|
|
147
147
|
});
|
|
148
148
|
})().catch((reason) => {
|
|
149
|
-
|
|
149
|
+
if (typeof reason === "string") {
|
|
150
|
+
throw new Error(reason);
|
|
151
|
+
}
|
|
152
|
+
throw reason;
|
|
150
153
|
}),
|
|
151
|
-
...
|
|
154
|
+
...npmInstallPaths.map((path, index) => {
|
|
152
155
|
return execute(`cd "${resolve(process.cwd(), path)}"; npm ${isCI ? "ci --omit=dev" : "install"}`)
|
|
153
156
|
.then(() => {
|
|
154
|
-
console.log(`Additional npm install ${index + 1} done. (${convertMeasureToPrettyString(performance.measure(`additional npm install ${index + 1}`, "Start"))})`);
|
|
157
|
+
console.log(`Additional npm install ${(index + 1).toString()} done. (${convertMeasureToPrettyString(performance.measure(`additional npm install ${(index + 1).toString()}`, "Start"))})`);
|
|
155
158
|
})
|
|
156
159
|
.catch((error) => {
|
|
157
160
|
console.error(error);
|
|
158
|
-
throw new Error(`Failed to run additional npm install ${index + 1}.`);
|
|
161
|
+
throw new Error(`Failed to run additional npm install ${(index + 1).toString()}.`);
|
|
159
162
|
});
|
|
160
|
-
})
|
|
163
|
+
}),
|
|
161
164
|
])
|
|
162
165
|
.then(async (results) => {
|
|
163
166
|
await stopRunningMessage();
|
|
@@ -167,7 +170,7 @@ export async function handler() {
|
|
|
167
170
|
console.error(results
|
|
168
171
|
.filter((result) => result.status === "rejected")
|
|
169
172
|
.map((result) => {
|
|
170
|
-
return `- ${result.reason}`;
|
|
173
|
+
return `- ${typeof result.reason === "string" ? result.reason : "Unknown reason."}`;
|
|
171
174
|
})
|
|
172
175
|
.join(`\n`));
|
|
173
176
|
}
|
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,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,
|
|
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,uBA+BlD"}
|
package/dist/utils.js
CHANGED
|
@@ -33,20 +33,20 @@ export function toCamelCase(text) {
|
|
|
33
33
|
});
|
|
34
34
|
}
|
|
35
35
|
export function convertMeasureToPrettyString(measure) {
|
|
36
|
-
const duration =
|
|
36
|
+
const duration = measure.duration;
|
|
37
37
|
if (duration < 1) {
|
|
38
|
-
return `${duration * 1000}µs`;
|
|
38
|
+
return `${(duration * 1000).toString()}µs`;
|
|
39
39
|
}
|
|
40
40
|
if (duration < 999) {
|
|
41
|
-
return `${Math.round(duration)}ms`;
|
|
41
|
+
return `${Math.round(duration).toString()}ms`;
|
|
42
42
|
}
|
|
43
43
|
const timeInSeconds = Number((duration / 1000).toFixed(2));
|
|
44
44
|
if (timeInSeconds < 60) {
|
|
45
|
-
return `${timeInSeconds}s`;
|
|
45
|
+
return `${timeInSeconds.toString()}s`;
|
|
46
46
|
}
|
|
47
47
|
const minutes = Math.floor(timeInSeconds / 60);
|
|
48
48
|
const seconds = Math.ceil(timeInSeconds % 60);
|
|
49
|
-
return `${minutes}m ${seconds}s`;
|
|
49
|
+
return `${minutes.toString()}m ${seconds.toString()}s`;
|
|
50
50
|
}
|
|
51
51
|
export function startRunningMessage(message) {
|
|
52
52
|
let $i = 3;
|
|
@@ -63,19 +63,17 @@ export function startRunningMessage(message) {
|
|
|
63
63
|
process.stdout.write(`${message}${".".repeat($i)}\r`);
|
|
64
64
|
}, 200);
|
|
65
65
|
return async () => {
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
resolve();
|
|
71
|
-
});
|
|
66
|
+
clearInterval(interval);
|
|
67
|
+
await new Promise((resolve) => {
|
|
68
|
+
process.stdout.clearLine(0, () => {
|
|
69
|
+
resolve();
|
|
72
70
|
});
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
71
|
+
});
|
|
72
|
+
await new Promise((resolve) => {
|
|
73
|
+
process.stdout.cursorTo(0, () => {
|
|
74
|
+
resolve();
|
|
77
75
|
});
|
|
78
|
-
}
|
|
76
|
+
});
|
|
79
77
|
};
|
|
80
78
|
}
|
|
81
79
|
return async () => {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@atomicsmash/cli",
|
|
3
|
-
"version": "11.0.0
|
|
3
|
+
"version": "11.0.0",
|
|
4
4
|
"description": "A collection of CLI tools by Atomic Smash.",
|
|
5
5
|
"keywords": [],
|
|
6
6
|
"homepage": "https://www.atomicsmash.co.uk/",
|
|
@@ -40,8 +40,8 @@
|
|
|
40
40
|
"lint:types": "tsc -b"
|
|
41
41
|
},
|
|
42
42
|
"dependencies": {
|
|
43
|
-
"@atomicsmash/date-php": "^2.2.0
|
|
44
|
-
"@atomicsmash/smash-config": "^1.0.2
|
|
43
|
+
"@atomicsmash/date-php": "^2.2.0",
|
|
44
|
+
"@atomicsmash/smash-config": "^1.0.2",
|
|
45
45
|
"@types/vinyl": "^2.0.12",
|
|
46
46
|
"glob-promise": "^6.0.7",
|
|
47
47
|
"svg-sprite": "^2.0.4",
|
|
@@ -49,8 +49,9 @@
|
|
|
49
49
|
"yargs": "^18.0.0"
|
|
50
50
|
},
|
|
51
51
|
"devDependencies": {
|
|
52
|
-
"@atomicsmash/blocks-helpers": "^7.2.2
|
|
53
|
-
"@types/svg-sprite": "^0.0.39"
|
|
52
|
+
"@atomicsmash/blocks-helpers": "^7.2.2",
|
|
53
|
+
"@types/svg-sprite": "^0.0.39",
|
|
54
|
+
"type-fest": "^5.6.0"
|
|
54
55
|
},
|
|
55
56
|
"peerDependencies": {
|
|
56
57
|
"dotenv": "^17.3.1",
|