@atomicsmash/cli 10.0.0-beta.1 → 10.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.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 +2 -1
- package/dist/commands/setup.d.ts.map +1 -1
- package/dist/commands/setup.js +8 -1
- 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 +5 -5
|
@@ -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:
|
|
@@ -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,kBA8Q5B"}
|
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() {
|
|
@@ -60,6 +61,10 @@ export async function handler() {
|
|
|
60
61
|
});
|
|
61
62
|
})(),
|
|
62
63
|
(async () => {
|
|
64
|
+
const ONE_MINUTE_IN_MS = 60000;
|
|
65
|
+
const timeout = setTimeout(() => {
|
|
66
|
+
throw new Error("Herd/Valet commands timed out. Please try again.");
|
|
67
|
+
}, ONE_MINUTE_IN_MS * 1.5);
|
|
63
68
|
if (await execute(`herd --version`)
|
|
64
69
|
.then(() => true)
|
|
65
70
|
.catch(() => false)) {
|
|
@@ -88,6 +93,7 @@ export async function handler() {
|
|
|
88
93
|
await execute(`herd isolate`)
|
|
89
94
|
.then(() => {
|
|
90
95
|
console.log(`Herd is isolated. (${convertMeasureToPrettyString(performance.measure("herd isolate", "herd link done"))})`);
|
|
96
|
+
clearTimeout(timeout);
|
|
91
97
|
})
|
|
92
98
|
.catch((error) => {
|
|
93
99
|
console.error(error);
|
|
@@ -99,6 +105,7 @@ export async function handler() {
|
|
|
99
105
|
.catch(() => false)) {
|
|
100
106
|
await execute(`valet link ${projectName} --secure --isolate`)
|
|
101
107
|
.then(() => {
|
|
108
|
+
clearTimeout(timeout);
|
|
102
109
|
console.log(`Valet is linked, secured and isolated. (${convertMeasureToPrettyString(performance.measure("herd-or-valet", "Start"))})`);
|
|
103
110
|
})
|
|
104
111
|
.catch((error) => {
|
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
|
|
3
|
+
"version": "10.0.0",
|
|
4
4
|
"description": "A collection of CLI tools by Atomic Smash.",
|
|
5
5
|
"keywords": [],
|
|
6
6
|
"homepage": "https://www.atomicsmash.co.uk/",
|
|
@@ -41,19 +41,19 @@
|
|
|
41
41
|
},
|
|
42
42
|
"dependencies": {
|
|
43
43
|
"@atomicsmash/date-php": "^2.1.0",
|
|
44
|
+
"@atomicsmash/smash-config": "^1.0.0",
|
|
44
45
|
"@types/vinyl": "^2.0.12",
|
|
45
|
-
"cosmiconfig": "^9.0.0",
|
|
46
46
|
"glob-promise": "^6.0.7",
|
|
47
47
|
"svg-sprite": "^2.0.4",
|
|
48
48
|
"vinyl": "^3.0.1",
|
|
49
49
|
"yargs": "^18.0.0"
|
|
50
50
|
},
|
|
51
51
|
"devDependencies": {
|
|
52
|
-
"@atomicsmash/blocks-helpers": "^7.2.0
|
|
52
|
+
"@atomicsmash/blocks-helpers": "^7.2.0",
|
|
53
53
|
"@types/svg-sprite": "^0.0.39"
|
|
54
54
|
},
|
|
55
55
|
"peerDependencies": {
|
|
56
|
-
"dotenv": "^
|
|
57
|
-
"typescript": "
|
|
56
|
+
"dotenv": "^17.2.3",
|
|
57
|
+
"typescript": "~5.9.3"
|
|
58
58
|
}
|
|
59
59
|
}
|