@aerogel/cli 0.0.0-next.bf95405357e75d2e8b0268a5e8ce7b2b7dd0c895 → 0.0.0-next.c33ad773d3eb977461630ff22012d99eeedf46cb
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/aerogel-cli.js +194 -229
- package/dist/aerogel-cli.js.map +1 -1
- package/package.json +1 -1
- package/src/cli.ts +0 -2
- package/src/commands/generate-component.test.ts +2 -2
- package/src/commands/install.test.ts +8 -0
- package/src/commands/install.ts +4 -3
- package/src/plugins/LocalFirst.ts +9 -0
- package/src/plugins/Plugin.ts +3 -2
- package/src/plugins/Solid.ts +1 -1
- package/src/plugins/Soukai.ts +1 -1
- package/templates/app/package.json +3 -3
- package/templates/app/src/App.vue +2 -2
- package/templates/app/src/assets/css/main.css +1 -1
- package/templates/component-button/[component.name].vue +2 -2
- package/templates/component-checkbox/[component.name].vue +9 -9
- package/templates/component-checkbox-story/[component.name].story.vue +5 -5
- package/templates/component-input/[component.name].vue +6 -6
- package/templates/component-input-story/[component.name].story.vue +4 -4
- package/src/commands/generate-overrides.ts +0 -85
- package/templates/overrides/components/index.ts +0 -15
- package/templates/overrides/components/overrides/AlertModal.vue +0 -11
- package/templates/overrides/components/overrides/ConfirmModal.vue +0 -20
- package/templates/overrides/components/overrides/ErrorReportModal.vue +0 -35
- package/templates/overrides/components/overrides/LoadingModal.vue +0 -12
- package/templates/overrides/components/overrides/ModalWrapper.vue +0 -22
- package/templates/overrides/components/overrides/SnackbarNotification.vue +0 -34
- package/templates/overrides-story/Overrides.story.vue +0 -86
package/dist/aerogel-cli.js
CHANGED
|
@@ -1,26 +1,26 @@
|
|
|
1
1
|
var Q = Object.defineProperty;
|
|
2
|
-
var X = (
|
|
3
|
-
var
|
|
2
|
+
var X = (a, e, t) => e in a ? Q(a, e, { enumerable: !0, configurable: !0, writable: !0, value: t }) : a[e] = t;
|
|
3
|
+
var r = (a, e, t) => X(a, typeof e != "symbol" ? e + "" : e, t);
|
|
4
4
|
import { Command as Z } from "commander";
|
|
5
|
-
import { existsSync as
|
|
6
|
-
import { facade as
|
|
7
|
-
import { fileURLToPath as
|
|
8
|
-
import { resolve as
|
|
5
|
+
import { existsSync as O, lstatSync as E, readFileSync as z, readdirSync as G, mkdirSync as V, writeFileSync as ee } from "node:fs";
|
|
6
|
+
import { facade as C, stringMatchAll as te, toString as ie, stringMatch as se, arrayFrom as A, stringToSlug as N, stringToTitleCase as ne, arrayFilter as ae, stringToStudlyCase as re, formatCodeBlock as T, stringToCamelCase as M, fail as oe } from "@noeldemartin/utils";
|
|
7
|
+
import { fileURLToPath as k, URL as x } from "node:url";
|
|
8
|
+
import { resolve as B, dirname as H, basename as ce } from "node:path";
|
|
9
9
|
import P from "chalk";
|
|
10
|
-
import { cursorTo as
|
|
10
|
+
import { cursorTo as le, clearLine as pe } from "node:readline";
|
|
11
11
|
import ue from "mustache";
|
|
12
|
-
import { Project as
|
|
13
|
-
import { exec as
|
|
14
|
-
class
|
|
12
|
+
import { Project as de, SyntaxKind as F, Node as u } from "ts-morph";
|
|
13
|
+
import { exec as ge } from "node:child_process";
|
|
14
|
+
class me {
|
|
15
15
|
contains(e, t) {
|
|
16
16
|
var i;
|
|
17
17
|
return !!((i = this.read(e)) != null && i.includes(t));
|
|
18
18
|
}
|
|
19
19
|
exists(e) {
|
|
20
|
-
return
|
|
20
|
+
return O(e);
|
|
21
21
|
}
|
|
22
22
|
isSymlink(e) {
|
|
23
|
-
return
|
|
23
|
+
return E(e).isSymbolicLink();
|
|
24
24
|
}
|
|
25
25
|
read(e) {
|
|
26
26
|
return this.isFile(e) ? z(e).toString() : null;
|
|
@@ -28,38 +28,38 @@ class fe {
|
|
|
28
28
|
getFiles(e) {
|
|
29
29
|
const t = G(e, { withFileTypes: !0 }), i = [];
|
|
30
30
|
for (const s of t) {
|
|
31
|
-
const n =
|
|
31
|
+
const n = B(e, s.name);
|
|
32
32
|
s.isDirectory() ? i.push(...this.getFiles(n)) : i.push(n);
|
|
33
33
|
}
|
|
34
34
|
return i;
|
|
35
35
|
}
|
|
36
36
|
isDirectory(e) {
|
|
37
|
-
return this.exists(e) &&
|
|
37
|
+
return this.exists(e) && E(e).isDirectory();
|
|
38
38
|
}
|
|
39
39
|
isFile(e) {
|
|
40
|
-
return this.exists(e) &&
|
|
40
|
+
return this.exists(e) && E(e).isFile();
|
|
41
41
|
}
|
|
42
42
|
isEmptyDirectory(e) {
|
|
43
43
|
return this.isDirectory(e) ? this.getFiles(e).length === 0 : !1;
|
|
44
44
|
}
|
|
45
45
|
makeDirectory(e) {
|
|
46
|
-
|
|
46
|
+
V(e, { recursive: !0 });
|
|
47
47
|
}
|
|
48
48
|
write(e, t) {
|
|
49
|
-
|
|
49
|
+
O(H(e)) || V(H(e), { recursive: !0 }), ee(e, t);
|
|
50
50
|
}
|
|
51
51
|
}
|
|
52
|
-
const c =
|
|
53
|
-
class
|
|
52
|
+
const c = C(me);
|
|
53
|
+
class fe {
|
|
54
54
|
constructor() {
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
55
|
+
r(this, "renderInfo", P.hex("#00ffff"));
|
|
56
|
+
r(this, "renderSuccess", P.hex("#00ff00"));
|
|
57
|
+
r(this, "renderError", P.hex("#ff0000"));
|
|
58
58
|
}
|
|
59
59
|
async animate(e, t) {
|
|
60
|
-
const i = (
|
|
61
|
-
const
|
|
62
|
-
this.stdout(
|
|
60
|
+
const i = (d = "", w = !1) => {
|
|
61
|
+
const L = this.renderInfo(this.renderMarkdown(e) + (w ? "..." : ".".repeat(s % 4))) + d;
|
|
62
|
+
this.stdout(L);
|
|
63
63
|
};
|
|
64
64
|
let s = 0;
|
|
65
65
|
i();
|
|
@@ -106,26 +106,26 @@ class he {
|
|
|
106
106
|
console.log(e);
|
|
107
107
|
}
|
|
108
108
|
stdout(e) {
|
|
109
|
-
|
|
109
|
+
le(process.stdout, 0), pe(process.stdout, 0), process.stdout.write(e);
|
|
110
110
|
}
|
|
111
111
|
}
|
|
112
|
-
const
|
|
113
|
-
class
|
|
112
|
+
const o = C(fe);
|
|
113
|
+
class v {
|
|
114
114
|
constructor(e) {
|
|
115
115
|
this.path = e;
|
|
116
116
|
}
|
|
117
117
|
static instantiate(e, t = "./", i = {}) {
|
|
118
|
-
return new
|
|
118
|
+
return new v(e).instantiate(t, i);
|
|
119
119
|
}
|
|
120
120
|
instantiate(e, t = {}) {
|
|
121
121
|
const i = this.getFilenameReplacements(t), s = [];
|
|
122
122
|
e = `${e}/`.replace(/\/\//, "/");
|
|
123
123
|
for (const n of c.getFiles(this.path)) {
|
|
124
124
|
const l = Object.entries(i).reduce(
|
|
125
|
-
(
|
|
125
|
+
(L, [Y, _]) => L.replaceAll(Y, _),
|
|
126
126
|
n.substring(this.path.length + 1)
|
|
127
|
-
),
|
|
128
|
-
c.write(
|
|
127
|
+
), d = z(n).toString(), w = e + (l.endsWith(".template") ? l.slice(0, -9) : l);
|
|
128
|
+
c.write(w, ue.render(d, t, void 0, ["<%", "%>"])), s.push(w);
|
|
129
129
|
}
|
|
130
130
|
return s;
|
|
131
131
|
}
|
|
@@ -139,55 +139,55 @@ class f {
|
|
|
139
139
|
);
|
|
140
140
|
}
|
|
141
141
|
}
|
|
142
|
-
function
|
|
142
|
+
function he(a = "") {
|
|
143
143
|
if (c.contains(
|
|
144
|
-
|
|
144
|
+
k(new x(
|
|
145
145
|
/* @vite-ignore */
|
|
146
146
|
"../../../package.json",
|
|
147
147
|
import.meta.url
|
|
148
148
|
)),
|
|
149
149
|
'"packages/create-aerogel"'
|
|
150
150
|
))
|
|
151
|
-
return
|
|
151
|
+
return B(k(new x(
|
|
152
152
|
/* @vite-ignore */
|
|
153
153
|
"../",
|
|
154
154
|
import.meta.url
|
|
155
|
-
)),
|
|
155
|
+
)), a);
|
|
156
156
|
const e = c.read(
|
|
157
|
-
|
|
157
|
+
k(new x(
|
|
158
158
|
/* @vite-ignore */
|
|
159
159
|
"../../../../package.json",
|
|
160
160
|
import.meta.url
|
|
161
161
|
))
|
|
162
|
-
), t = se(e ?? "", /"@aerogel\/core": "file:(.*)\/aerogel-core-[\d.]*\.tgz"/), i = (t == null ? void 0 : t[1]) ??
|
|
163
|
-
return
|
|
162
|
+
), t = se(e ?? "", /"@aerogel\/core": "file:(.*)\/aerogel-core-[\d.]*\.tgz"/), i = (t == null ? void 0 : t[1]) ?? o.fail("Could not determine base path");
|
|
163
|
+
return B(i, a);
|
|
164
164
|
}
|
|
165
|
-
function
|
|
166
|
-
return
|
|
165
|
+
function f(a) {
|
|
166
|
+
return o.fail(`Could not find ${a} pack file, did you run 'npm pack'?`);
|
|
167
167
|
}
|
|
168
|
-
function
|
|
169
|
-
return c.getFiles(m(
|
|
168
|
+
function h(a) {
|
|
169
|
+
return c.getFiles(m(a)).find((e) => e.endsWith(".tgz")) ?? null;
|
|
170
170
|
}
|
|
171
|
-
function m(
|
|
172
|
-
return
|
|
171
|
+
function m(a) {
|
|
172
|
+
return he(`../${a}`);
|
|
173
173
|
}
|
|
174
|
-
function
|
|
175
|
-
return
|
|
174
|
+
function j(a) {
|
|
175
|
+
return k(new x(
|
|
176
176
|
/* @vite-ignore */
|
|
177
|
-
`../templates/${
|
|
177
|
+
`../templates/${a}`,
|
|
178
178
|
import.meta.url
|
|
179
179
|
));
|
|
180
180
|
}
|
|
181
|
-
class
|
|
181
|
+
class ye {
|
|
182
182
|
constructor() {
|
|
183
|
-
|
|
183
|
+
r(this, "cwd", null);
|
|
184
184
|
}
|
|
185
185
|
setWorkingDirectory(e) {
|
|
186
186
|
this.cwd = e;
|
|
187
187
|
}
|
|
188
188
|
async run(e) {
|
|
189
189
|
await new Promise((t, i) => {
|
|
190
|
-
|
|
190
|
+
ge(e, { cwd: this.cwd ?? void 0 }, (s) => {
|
|
191
191
|
if (s) {
|
|
192
192
|
i(s);
|
|
193
193
|
return;
|
|
@@ -197,12 +197,12 @@ class ve {
|
|
|
197
197
|
});
|
|
198
198
|
}
|
|
199
199
|
}
|
|
200
|
-
const p =
|
|
201
|
-
class
|
|
200
|
+
const p = C(ye);
|
|
201
|
+
class ve {
|
|
202
202
|
constructor() {
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
this.project = new
|
|
203
|
+
r(this, "project");
|
|
204
|
+
r(this, "modifiedFiles");
|
|
205
|
+
this.project = new de({ tsConfigFilePath: "tsconfig.json" }), this.modifiedFiles = /* @__PURE__ */ new Set(), this.project.addSourceFilesAtPaths("src/**/*.ts"), this.project.addSourceFilesAtPaths("vite.config.ts"), this.project.addSourceFilesAtPaths("package.json");
|
|
206
206
|
}
|
|
207
207
|
addSourceFile(e) {
|
|
208
208
|
this.project.addSourceFilesAtPaths(e);
|
|
@@ -211,11 +211,11 @@ class we {
|
|
|
211
211
|
return this.project.getSourceFileOrThrow(e);
|
|
212
212
|
}
|
|
213
213
|
async format() {
|
|
214
|
-
await
|
|
214
|
+
await o.animate("Formatting modified files", async () => {
|
|
215
215
|
const e = c.exists("prettier.config.js") || c.contains("package.json", '"prettier": {'), t = c.exists(".eslintrc.js") || c.contains("package.json", '"eslintConfig"'), s = c.contains("package.json", '"prettier-eslint-cli"') ? (n) => p.run(`npx prettier-eslint ${n} --write`) : async (n) => {
|
|
216
216
|
e && await p.run(`npx prettier ${n} --write`), n.match(/\.(ts|js|vue)$/) && t && await p.run(`npx eslint ${n} --fix`);
|
|
217
217
|
};
|
|
218
|
-
await Promise.all(
|
|
218
|
+
await Promise.all(A(this.modifiedFiles).map(async (n) => s(n)));
|
|
219
219
|
});
|
|
220
220
|
}
|
|
221
221
|
async save(e) {
|
|
@@ -225,22 +225,22 @@ class we {
|
|
|
225
225
|
this.modifiedFiles.add(e);
|
|
226
226
|
}
|
|
227
227
|
}
|
|
228
|
-
class
|
|
228
|
+
class U {
|
|
229
229
|
constructor(e, t = {}) {
|
|
230
230
|
this.name = e, this.options = t;
|
|
231
231
|
}
|
|
232
232
|
create(e) {
|
|
233
|
-
c.exists(e) && (!c.isDirectory(e) || !c.isEmptyDirectory(e)) &&
|
|
233
|
+
c.exists(e) && (!c.isDirectory(e) || !c.isEmptyDirectory(e)) && o.fail(`Folder at '${e}' already exists!`), v.instantiate(j("app"), e, {
|
|
234
234
|
app: {
|
|
235
235
|
name: this.name,
|
|
236
|
-
slug:
|
|
236
|
+
slug: N(this.name)
|
|
237
237
|
},
|
|
238
238
|
dependencies: this.getDependencies(),
|
|
239
239
|
contentPath: this.options.linkedLocal ? `${m("core")}/dist/**/*.js` : "./node_modules/@aerogel/core/dist/**/*.js"
|
|
240
240
|
});
|
|
241
241
|
}
|
|
242
242
|
edit() {
|
|
243
|
-
return new
|
|
243
|
+
return new ve();
|
|
244
244
|
}
|
|
245
245
|
getDependencies() {
|
|
246
246
|
const e = (t) => Object.entries(t).reduce(
|
|
@@ -255,12 +255,12 @@ class K {
|
|
|
255
255
|
aerogelPluginSoukai: m("plugin-soukai"),
|
|
256
256
|
aerogelVite: m("vite")
|
|
257
257
|
}) : this.options.local ? e({
|
|
258
|
-
aerogelCli:
|
|
259
|
-
aerogelCore:
|
|
260
|
-
aerogelCypress:
|
|
261
|
-
aerogelPluginI18n:
|
|
262
|
-
aerogelPluginSoukai:
|
|
263
|
-
aerogelVite:
|
|
258
|
+
aerogelCli: h("cli") ?? f("cli"),
|
|
259
|
+
aerogelCore: h("core") ?? f("core"),
|
|
260
|
+
aerogelCypress: h("cypress") ?? f("cypress"),
|
|
261
|
+
aerogelPluginI18n: h("plugin-i18n") ?? f("plugin-i18n"),
|
|
262
|
+
aerogelPluginSoukai: h("plugin-soukai") ?? f("plugin-soukai"),
|
|
263
|
+
aerogelVite: h("vite") ?? f("vite")
|
|
264
264
|
}) : {
|
|
265
265
|
aerogelCli: "next",
|
|
266
266
|
aerogelCore: "next",
|
|
@@ -295,20 +295,20 @@ class g {
|
|
|
295
295
|
if (t != null && t.includes("@aerogel/core") || e && c.isDirectory(e))
|
|
296
296
|
return;
|
|
297
297
|
const i = e ? `${e} folder does not exist.` : "package.json does not contain @aerogel/core.";
|
|
298
|
-
|
|
298
|
+
o.fail(`${i} Are you sure this is an Aerogel app?`);
|
|
299
299
|
}
|
|
300
300
|
}
|
|
301
|
-
|
|
302
|
-
class
|
|
301
|
+
r(g, "command", ""), r(g, "description", ""), r(g, "parameters", []), r(g, "options", {});
|
|
302
|
+
class S extends g {
|
|
303
303
|
constructor(t, i = {}) {
|
|
304
304
|
super();
|
|
305
|
-
|
|
306
|
-
|
|
305
|
+
r(this, "path");
|
|
306
|
+
r(this, "options");
|
|
307
307
|
this.path = t, this.options = i;
|
|
308
308
|
}
|
|
309
309
|
async run() {
|
|
310
|
-
const t = this.path, i = this.options.name ?? ne(
|
|
311
|
-
p.setWorkingDirectory(t), await this.createApp(i, t), await this.installDependencies(), await this.initializeGit(),
|
|
310
|
+
const t = this.path, i = this.options.name ?? ne(ce(t));
|
|
311
|
+
p.setWorkingDirectory(t), await this.createApp(i, t), await this.installDependencies(), await this.initializeGit(), o.success(`
|
|
312
312
|
|
|
313
313
|
That's it! You can start working on **${i}** doing the following:
|
|
314
314
|
|
|
@@ -319,23 +319,23 @@ class $ extends g {
|
|
|
319
319
|
`);
|
|
320
320
|
}
|
|
321
321
|
async createApp(t, i) {
|
|
322
|
-
|
|
322
|
+
o.info(`Creating **${t}**...`), new U(t, {
|
|
323
323
|
local: this.options.local,
|
|
324
324
|
linkedLocal: this.options.local && !this.options.copy
|
|
325
325
|
}).create(i);
|
|
326
326
|
}
|
|
327
327
|
async installDependencies() {
|
|
328
|
-
await
|
|
328
|
+
await o.animate("Installing dependencies", async () => {
|
|
329
329
|
await p.run("npm install");
|
|
330
330
|
});
|
|
331
331
|
}
|
|
332
332
|
async initializeGit() {
|
|
333
|
-
await
|
|
333
|
+
await o.animate("Initializing git", async () => {
|
|
334
334
|
await p.run("git init"), await p.run("git add ."), await p.run('git commit -m "Start"');
|
|
335
335
|
});
|
|
336
336
|
}
|
|
337
337
|
}
|
|
338
|
-
|
|
338
|
+
r(S, "command", "create"), r(S, "description", "Create AerogelJS app"), r(S, "parameters", [["path", "Application path"]]), r(S, "options", {
|
|
339
339
|
name: "Application name",
|
|
340
340
|
local: {
|
|
341
341
|
type: "boolean",
|
|
@@ -347,102 +347,102 @@ a($, "command", "create"), a($, "description", "Create AerogelJS app"), a($, "pa
|
|
|
347
347
|
}
|
|
348
348
|
});
|
|
349
349
|
function q() {
|
|
350
|
-
return new
|
|
350
|
+
return new U("");
|
|
351
351
|
}
|
|
352
|
-
function
|
|
352
|
+
function we() {
|
|
353
353
|
return c.contains("package.json", '"@aerogel/core": "file:');
|
|
354
354
|
}
|
|
355
|
-
function
|
|
355
|
+
function ke() {
|
|
356
356
|
return c.isSymlink("node_modules/@aerogel/core");
|
|
357
357
|
}
|
|
358
|
-
function
|
|
359
|
-
if (!
|
|
358
|
+
function y(a, e = {}) {
|
|
359
|
+
if (!a)
|
|
360
360
|
return;
|
|
361
|
-
const t = e.guard ?? (() => !0), i = e.validate ?? (() => !0), s =
|
|
362
|
-
return
|
|
361
|
+
const t = e.guard ?? (() => !0), i = e.validate ?? (() => !0), s = A(e.skip ?? []);
|
|
362
|
+
return a.forEachDescendant((n, l) => {
|
|
363
363
|
if (t(n) && i(n))
|
|
364
364
|
return n;
|
|
365
|
-
const
|
|
366
|
-
s.includes(
|
|
365
|
+
const d = n.getKind();
|
|
366
|
+
s.includes(d) && l.skip();
|
|
367
367
|
});
|
|
368
368
|
}
|
|
369
|
-
function
|
|
370
|
-
if (!(!
|
|
371
|
-
return
|
|
369
|
+
function K(a, e) {
|
|
370
|
+
if (!(!a || !e(a)))
|
|
371
|
+
return a;
|
|
372
372
|
}
|
|
373
|
-
class
|
|
373
|
+
class $ extends g {
|
|
374
374
|
constructor(t, i = {}) {
|
|
375
375
|
super();
|
|
376
|
-
|
|
377
|
-
|
|
376
|
+
r(this, "path");
|
|
377
|
+
r(this, "options");
|
|
378
378
|
this.path = t, this.options = i;
|
|
379
379
|
}
|
|
380
380
|
async validate() {
|
|
381
|
-
ae([this.options.button, this.options.input, this.options.checkbox]).length > 1 &&
|
|
381
|
+
ae([this.options.button, this.options.input, this.options.checkbox]).length > 1 && o.fail("Can only use one of 'button', 'input', or 'checkbox' flags!");
|
|
382
382
|
}
|
|
383
383
|
async run() {
|
|
384
384
|
this.assertAerogelOrDirectory("src/components"), this.assertHistoireInstalled();
|
|
385
385
|
const t = /* @__PURE__ */ new Set(), [i, s] = this.parsePathComponents();
|
|
386
386
|
await this.createComponent(i, s, t), await this.createStory(i, s, t), await this.declareComponents();
|
|
387
|
-
const n =
|
|
387
|
+
const n = A(t).map((l) => `- ${l}`).join(`
|
|
388
388
|
`);
|
|
389
|
-
|
|
389
|
+
o.info(`${s} component created successfully! The following files were created:
|
|
390
390
|
|
|
391
391
|
${n}`);
|
|
392
392
|
}
|
|
393
393
|
assertHistoireInstalled() {
|
|
394
|
-
this.options.story && !c.contains("package.json", '"histoire"') && !c.contains("package.json", '"@aerogel/histoire"') &&
|
|
394
|
+
this.options.story && !c.contains("package.json", '"histoire"') && !c.contains("package.json", '"@aerogel/histoire"') && o.fail(`
|
|
395
395
|
Histoire is not installed yet! You can install it running:
|
|
396
396
|
npx gel install histoire
|
|
397
397
|
`);
|
|
398
398
|
}
|
|
399
399
|
async createComponent(t, i, s) {
|
|
400
|
-
await
|
|
401
|
-
c.exists(`src/components/${this.path}.vue`) &&
|
|
400
|
+
await o.animate("Creating component", async () => {
|
|
401
|
+
c.exists(`src/components/${this.path}.vue`) && o.fail(`${this.path} component already exists!`);
|
|
402
402
|
const n = this.options.input ? "component-input" : this.options.button ? "component-button" : this.options.checkbox ? "component-checkbox" : "component";
|
|
403
|
-
|
|
403
|
+
v.instantiate(j(n), `src/components/${t}`, {
|
|
404
404
|
component: {
|
|
405
405
|
name: i,
|
|
406
|
-
slug:
|
|
406
|
+
slug: N(i)
|
|
407
407
|
}
|
|
408
|
-
}).forEach((
|
|
408
|
+
}).forEach((d) => s.add(d));
|
|
409
409
|
});
|
|
410
410
|
}
|
|
411
411
|
async createStory(t, i, s) {
|
|
412
|
-
this.options.story && await
|
|
412
|
+
this.options.story && await o.animate("Creating story", async () => {
|
|
413
413
|
const n = this.options.input ? "component-input-story" : this.options.button ? "component-button-story" : this.options.checkbox ? "component-checkbox-story" : "component-story";
|
|
414
|
-
|
|
414
|
+
v.instantiate(j(n), `src/components/${t}`, {
|
|
415
415
|
component: {
|
|
416
416
|
name: i,
|
|
417
|
-
slug:
|
|
417
|
+
slug: N(i)
|
|
418
418
|
}
|
|
419
|
-
}).forEach((
|
|
419
|
+
}).forEach((d) => s.add(d));
|
|
420
420
|
});
|
|
421
421
|
}
|
|
422
422
|
async declareComponents() {
|
|
423
423
|
const t = q().edit(), i = t.requireSourceFile("vite.config.ts"), s = this.getComponentDirsArray(i);
|
|
424
424
|
if (!s)
|
|
425
|
-
return
|
|
426
|
-
s.getDescendantsOfKind(
|
|
425
|
+
return o.fail("Could not find component dirs declaration in vite config!");
|
|
426
|
+
s.getDescendantsOfKind(F.StringLiteral).some((n) => n.getText() === "'src/components'") || (await o.animate("Updating vite config", async () => {
|
|
427
427
|
s.addElement("'src/components'"), await t.save(i);
|
|
428
428
|
}), await t.format());
|
|
429
429
|
}
|
|
430
430
|
getComponentDirsArray(t) {
|
|
431
|
-
const i =
|
|
432
|
-
guard:
|
|
431
|
+
const i = y(t, {
|
|
432
|
+
guard: u.isCallExpression,
|
|
433
433
|
validate: (l) => l.getText().startsWith("Components("),
|
|
434
|
-
skip:
|
|
434
|
+
skip: F.ImportDeclaration
|
|
435
435
|
});
|
|
436
436
|
if (!i)
|
|
437
437
|
return null;
|
|
438
|
-
const s =
|
|
439
|
-
guard:
|
|
438
|
+
const s = y(i, {
|
|
439
|
+
guard: u.isPropertyAssignment,
|
|
440
440
|
validate: (l) => l.getName() === "dirs"
|
|
441
441
|
}), n = s == null ? void 0 : s.getInitializer();
|
|
442
|
-
return
|
|
442
|
+
return u.isArrayLiteralExpression(n) ? n : this.declareComponentDirsArray(i);
|
|
443
443
|
}
|
|
444
444
|
declareComponentDirsArray(t) {
|
|
445
|
-
const i =
|
|
445
|
+
const i = y(t, { guard: u.isObjectLiteralExpression }), s = i == null ? void 0 : i.addPropertyAssignment({
|
|
446
446
|
name: "dirs",
|
|
447
447
|
initializer: "[]"
|
|
448
448
|
});
|
|
@@ -453,9 +453,9 @@ ${n}`);
|
|
|
453
453
|
return t === -1 ? ["", this.path] : [this.path.substring(0, t), this.path.substring(t + 1)];
|
|
454
454
|
}
|
|
455
455
|
}
|
|
456
|
-
|
|
456
|
+
r($, "command", "generate:component"), r($, "description", "Generate an AerogelJS Component"), r($, "parameters", [
|
|
457
457
|
["path", "Component path (relative to components folder; extension not necessary)"]
|
|
458
|
-
]),
|
|
458
|
+
]), r($, "options", {
|
|
459
459
|
button: {
|
|
460
460
|
description: "Create a custom button",
|
|
461
461
|
type: "boolean"
|
|
@@ -473,16 +473,16 @@ a(b, "command", "generate:component"), a(b, "description", "Generate an AerogelJ
|
|
|
473
473
|
type: "boolean"
|
|
474
474
|
}
|
|
475
475
|
});
|
|
476
|
-
class
|
|
476
|
+
class b extends g {
|
|
477
477
|
constructor(t, i = {}) {
|
|
478
478
|
super();
|
|
479
|
-
|
|
480
|
-
|
|
479
|
+
r(this, "name");
|
|
480
|
+
r(this, "options");
|
|
481
481
|
this.name = t, this.options = i;
|
|
482
482
|
}
|
|
483
483
|
async run() {
|
|
484
|
-
this.assertAerogelOrDirectory("src/models"), c.exists(`src/models/${this.name}.ts`) &&
|
|
485
|
-
const t = await
|
|
484
|
+
this.assertAerogelOrDirectory("src/models"), c.exists(`src/models/${this.name}.ts`) && o.fail(`${this.name} model already exists!`), this.assertSoukaiInstalled();
|
|
485
|
+
const t = await o.animate("Creating model", async () => v.instantiate(j("model"), "src/models", {
|
|
486
486
|
model: {
|
|
487
487
|
name: this.name,
|
|
488
488
|
fieldsDefinition: this.getFieldsDefinition()
|
|
@@ -490,7 +490,7 @@ class F extends g {
|
|
|
490
490
|
soukaiImports: this.options.fields ? "FieldType, defineModelSchema" : "defineModelSchema"
|
|
491
491
|
}).map((s) => `- ${s}`).join(`
|
|
492
492
|
`));
|
|
493
|
-
|
|
493
|
+
o.info(`${this.name} model created successfully! The following files were created:
|
|
494
494
|
|
|
495
495
|
${t}`);
|
|
496
496
|
}
|
|
@@ -505,7 +505,7 @@ ${t}`);
|
|
|
505
505
|
required: l === "required"
|
|
506
506
|
};
|
|
507
507
|
}).reduce((i, s) => {
|
|
508
|
-
const n = s.required ?
|
|
508
|
+
const n = s.required ? T(`
|
|
509
509
|
${s.name}: {
|
|
510
510
|
type: FieldType.${s.type},
|
|
511
511
|
required: true,
|
|
@@ -514,77 +514,37 @@ ${t}`);
|
|
|
514
514
|
return i + `
|
|
515
515
|
${n},`;
|
|
516
516
|
}, "");
|
|
517
|
-
return
|
|
517
|
+
return T(t, { indent: 8 });
|
|
518
518
|
}
|
|
519
519
|
assertSoukaiInstalled() {
|
|
520
|
-
!c.contains("package.json", '"soukai"') && !c.contains("package.json", '"@aerogel/plugin-soukai"') &&
|
|
520
|
+
!c.contains("package.json", '"soukai"') && !c.contains("package.json", '"@aerogel/plugin-soukai"') && o.fail(`
|
|
521
521
|
Soukai is not installed yet! You can install it running:
|
|
522
522
|
npx gel install soukai
|
|
523
523
|
`);
|
|
524
524
|
}
|
|
525
525
|
}
|
|
526
|
-
|
|
526
|
+
r(b, "command", "generate:model"), r(b, "description", "Generate an AerogelJS Model"), r(b, "parameters", [["name", "Model name"]]), r(b, "options", {
|
|
527
527
|
fields: "Create model with the given fields"
|
|
528
528
|
});
|
|
529
|
-
class
|
|
530
|
-
constructor(t = {}) {
|
|
531
|
-
super();
|
|
532
|
-
a(this, "options");
|
|
533
|
-
this.options = t;
|
|
534
|
-
}
|
|
535
|
-
async run() {
|
|
536
|
-
this.assertAerogelOrDirectory("src/components"), this.assertHistoireInstalled();
|
|
537
|
-
const t = /* @__PURE__ */ new Set();
|
|
538
|
-
await this.createComponents(t), await this.createStory(t);
|
|
539
|
-
const i = I(t).map((s) => `- ${s}`).join(`
|
|
540
|
-
`);
|
|
541
|
-
r.info(`Overrides created successfully! The following files were created:
|
|
542
|
-
|
|
543
|
-
${i}`), r.info(`
|
|
544
|
-
Remember to declare your components in main.ts and main.histoire.ts!`);
|
|
545
|
-
}
|
|
546
|
-
assertHistoireInstalled() {
|
|
547
|
-
this.options.story && !c.contains("package.json", '"histoire"') && !c.contains("package.json", '"@aerogel/histoire"') && r.fail(`
|
|
548
|
-
Histoire is not installed yet! You can install it running:
|
|
549
|
-
npx gel install histoire
|
|
550
|
-
`);
|
|
551
|
-
}
|
|
552
|
-
async createComponents(t) {
|
|
553
|
-
await r.animate("Creating components", async () => {
|
|
554
|
-
c.exists("src/components/ModalWrapper.vue") && r.fail("ModalWrapper component already exists!"), f.instantiate(w("overrides"), "src").forEach((i) => t.add(i));
|
|
555
|
-
});
|
|
556
|
-
}
|
|
557
|
-
async createStory(t) {
|
|
558
|
-
this.options.story && await r.animate("Creating story", async () => {
|
|
559
|
-
f.instantiate(w("overrides-story"), "src/components/overrides/").forEach((i) => t.add(i));
|
|
560
|
-
});
|
|
561
|
-
}
|
|
562
|
-
}
|
|
563
|
-
a(D, "command", "generate:overrides"), a(D, "description", "Generate AerogelJS component overrides"), a(D, "options", {
|
|
564
|
-
story: {
|
|
565
|
-
description: "Create overrides story using Histoire",
|
|
566
|
-
type: "boolean"
|
|
567
|
-
}
|
|
568
|
-
});
|
|
569
|
-
class C extends g {
|
|
529
|
+
class I extends g {
|
|
570
530
|
constructor(t) {
|
|
571
531
|
super();
|
|
572
|
-
|
|
532
|
+
r(this, "name");
|
|
573
533
|
this.name = t;
|
|
574
534
|
}
|
|
575
535
|
async run() {
|
|
576
536
|
this.assertAerogelOrDirectory("src/services");
|
|
577
537
|
const t = /* @__PURE__ */ new Set(), i = q().edit();
|
|
578
538
|
await this.createService(t), await this.registerService(i), await i.format();
|
|
579
|
-
const s =
|
|
539
|
+
const s = A(t).map((n) => `- ${n}`).join(`
|
|
580
540
|
`);
|
|
581
|
-
|
|
541
|
+
o.info(`${this.name} service created successfully! The following files were created:
|
|
582
542
|
|
|
583
543
|
${s}`);
|
|
584
544
|
}
|
|
585
545
|
async createService(t) {
|
|
586
|
-
await
|
|
587
|
-
c.exists(`src/services/${this.name}.ts`) &&
|
|
546
|
+
await o.animate("Creating service", async () => {
|
|
547
|
+
c.exists(`src/services/${this.name}.ts`) && o.fail(`${this.name} service already exists!`), v.instantiate(j("service"), "src/services", {
|
|
588
548
|
service: {
|
|
589
549
|
name: this.name
|
|
590
550
|
}
|
|
@@ -592,16 +552,16 @@ ${s}`);
|
|
|
592
552
|
});
|
|
593
553
|
}
|
|
594
554
|
async registerService(t) {
|
|
595
|
-
await
|
|
555
|
+
await o.animate("Registering service", async () => {
|
|
596
556
|
c.exists("src/services/index.ts") || await this.createServicesIndex(t);
|
|
597
557
|
const i = t.requireSourceFile("src/services/index.ts"), s = this.getServicesObject(i);
|
|
598
558
|
if (!s)
|
|
599
|
-
return
|
|
559
|
+
return o.fail("Could not find services object in services config, please add it manually.");
|
|
600
560
|
i.addImportDeclaration({
|
|
601
561
|
defaultImport: this.name,
|
|
602
562
|
moduleSpecifier: `./${this.name}`
|
|
603
563
|
}), s.addPropertyAssignment({
|
|
604
|
-
name: `$${
|
|
564
|
+
name: `$${M(this.name)}`,
|
|
605
565
|
initializer: this.name
|
|
606
566
|
}), await t.save(i);
|
|
607
567
|
});
|
|
@@ -609,7 +569,7 @@ ${s}`);
|
|
|
609
569
|
async createServicesIndex(t) {
|
|
610
570
|
c.write(
|
|
611
571
|
"src/services/index.ts",
|
|
612
|
-
|
|
572
|
+
T(`
|
|
613
573
|
export const services = {};
|
|
614
574
|
|
|
615
575
|
export type AppServices = typeof services;
|
|
@@ -621,42 +581,42 @@ ${s}`);
|
|
|
621
581
|
), t.addSourceFile("src/services/index.ts");
|
|
622
582
|
const i = t.requireSourceFile("src/main.ts"), s = this.getBootstrapOptions(i);
|
|
623
583
|
if (!s)
|
|
624
|
-
return
|
|
584
|
+
return o.fail("Could not find options object in bootstrap config, please add the services manually.");
|
|
625
585
|
s.insertShorthandPropertyAssignment(0, { name: "services" }), i.addImportDeclaration({
|
|
626
586
|
namedImports: ["services"],
|
|
627
587
|
moduleSpecifier: "./services"
|
|
628
588
|
}), await t.save(i);
|
|
629
589
|
}
|
|
630
590
|
getBootstrapOptions(t) {
|
|
631
|
-
const i =
|
|
632
|
-
guard:
|
|
591
|
+
const i = y(t, {
|
|
592
|
+
guard: u.isCallExpression,
|
|
633
593
|
validate: (n) => n.getExpression().getText() === "bootstrap",
|
|
634
|
-
skip:
|
|
594
|
+
skip: F.ImportDeclaration
|
|
635
595
|
}), s = i == null ? void 0 : i.getArguments()[1];
|
|
636
|
-
return
|
|
596
|
+
return u.isObjectLiteralExpression(s) ? s : null;
|
|
637
597
|
}
|
|
638
598
|
getServicesObject(t) {
|
|
639
|
-
const i =
|
|
640
|
-
guard:
|
|
599
|
+
const i = y(t, {
|
|
600
|
+
guard: u.isVariableDeclaration,
|
|
641
601
|
validate: (n) => n.getName() === "services"
|
|
642
602
|
}), s = i == null ? void 0 : i.getInitializer();
|
|
643
|
-
return
|
|
603
|
+
return u.isObjectLiteralExpression(s) ? s : null;
|
|
644
604
|
}
|
|
645
605
|
}
|
|
646
|
-
|
|
647
|
-
class
|
|
606
|
+
r(I, "command", "generate:service"), r(I, "description", "Generate an AerogelJS Service"), r(I, "parameters", [["name", "Service name"]]);
|
|
607
|
+
class J extends g {
|
|
648
608
|
async run() {
|
|
649
|
-
|
|
609
|
+
o.info("[AerogelJS CLI info]"), o.info("Installation directory: " + k(new x(
|
|
650
610
|
/* @vite-ignore */
|
|
651
611
|
"./",
|
|
652
612
|
import.meta.url
|
|
653
613
|
)));
|
|
654
614
|
}
|
|
655
615
|
}
|
|
656
|
-
|
|
657
|
-
class
|
|
616
|
+
r(J, "command", "info"), r(J, "description", "Show debugging information about the CLI");
|
|
617
|
+
class W {
|
|
658
618
|
constructor(e) {
|
|
659
|
-
|
|
619
|
+
r(this, "name");
|
|
660
620
|
this.name = e;
|
|
661
621
|
}
|
|
662
622
|
async install() {
|
|
@@ -665,17 +625,17 @@ class U {
|
|
|
665
625
|
const e = q().edit();
|
|
666
626
|
await this.updateFiles(e), await e.format();
|
|
667
627
|
}
|
|
668
|
-
await this.afterInstall(),
|
|
628
|
+
await this.afterInstall(), o.info(`Plugin ${this.name} installed!`);
|
|
669
629
|
}
|
|
670
630
|
assertNotInstalled() {
|
|
671
|
-
c.contains("package.json", `"${this.getNpmPackageName()}"`) &&
|
|
631
|
+
c.contains("package.json", `"${this.getNpmPackageName()}"`) && o.fail(`${this.name} is already installed!`);
|
|
672
632
|
}
|
|
673
633
|
async beforeInstall() {
|
|
674
634
|
}
|
|
675
635
|
async afterInstall() {
|
|
676
636
|
}
|
|
677
637
|
async installDependencies() {
|
|
678
|
-
await
|
|
638
|
+
await o.animate("Installing plugin dependencies", async () => {
|
|
679
639
|
await this.installNpmDependencies();
|
|
680
640
|
});
|
|
681
641
|
}
|
|
@@ -684,22 +644,22 @@ class U {
|
|
|
684
644
|
}
|
|
685
645
|
async installNpmDependencies() {
|
|
686
646
|
const e = this.isForDevelopment() ? "--save-dev" : "";
|
|
687
|
-
if (
|
|
647
|
+
if (ke()) {
|
|
688
648
|
await p.run(`npm install file:${m(this.getLocalPackageName())} ${e}`);
|
|
689
649
|
return;
|
|
690
650
|
}
|
|
691
|
-
if (
|
|
692
|
-
const t =
|
|
651
|
+
if (we()) {
|
|
652
|
+
const t = h(this.getLocalPackageName()) ?? f(this.getLocalPackageName());
|
|
693
653
|
await p.run(`npm install file:${t} ${e}`);
|
|
694
654
|
return;
|
|
695
655
|
}
|
|
696
656
|
await p.run(`npm install ${this.getNpmPackageName()}@next --save-exact ${e}`);
|
|
697
657
|
}
|
|
698
658
|
async updateBootstrapConfig(e) {
|
|
699
|
-
await
|
|
659
|
+
await o.animate("Injecting plugin in bootstrap configuration", async () => {
|
|
700
660
|
const t = e.requireSourceFile("src/main.ts"), i = this.getBootstrapPluginsDeclaration(t);
|
|
701
661
|
if (!i)
|
|
702
|
-
return
|
|
662
|
+
return o.fail(`
|
|
703
663
|
Could not find plugins array in bootstrap config, please add the following manually:
|
|
704
664
|
|
|
705
665
|
${this.getBootstrapConfig()}
|
|
@@ -708,25 +668,25 @@ class U {
|
|
|
708
668
|
});
|
|
709
669
|
}
|
|
710
670
|
getBootstrapPluginsDeclaration(e) {
|
|
711
|
-
var l,
|
|
712
|
-
const t =
|
|
713
|
-
guard:
|
|
714
|
-
validate: (
|
|
715
|
-
skip:
|
|
716
|
-
}), i = t == null ? void 0 : t.getArguments()[1], s = (l =
|
|
717
|
-
return
|
|
671
|
+
var l, d;
|
|
672
|
+
const t = y(e, {
|
|
673
|
+
guard: u.isCallExpression,
|
|
674
|
+
validate: (w) => w.getExpression().getText() === "bootstrap",
|
|
675
|
+
skip: F.ImportDeclaration
|
|
676
|
+
}), i = t == null ? void 0 : t.getArguments()[1], s = (l = K(i, u.isObjectLiteralExpression)) == null ? void 0 : l.getProperty("plugins"), n = (d = K(s, u.isPropertyAssignment)) == null ? void 0 : d.getInitializer();
|
|
677
|
+
return u.isArrayLiteralExpression(n) ? n : null;
|
|
718
678
|
}
|
|
719
679
|
getTailwindContentArray(e) {
|
|
720
|
-
const t =
|
|
721
|
-
guard:
|
|
680
|
+
const t = y(e, {
|
|
681
|
+
guard: u.isPropertyAssignment,
|
|
722
682
|
validate: (s) => s.getName() === "content",
|
|
723
|
-
skip:
|
|
683
|
+
skip: F.JSDoc
|
|
724
684
|
}), i = t == null ? void 0 : t.getInitializer();
|
|
725
|
-
return
|
|
685
|
+
return u.isArrayLiteralExpression(i) ? i : null;
|
|
726
686
|
}
|
|
727
687
|
getBootstrapImport() {
|
|
728
688
|
return {
|
|
729
|
-
defaultImport: this.name,
|
|
689
|
+
defaultImport: M(this.name),
|
|
730
690
|
moduleSpecifier: `@aerogel/plugin-${this.name}`
|
|
731
691
|
};
|
|
732
692
|
}
|
|
@@ -740,10 +700,15 @@ class U {
|
|
|
740
700
|
return !1;
|
|
741
701
|
}
|
|
742
702
|
getBootstrapConfig() {
|
|
743
|
-
return `${this.name}()`;
|
|
703
|
+
return `${M(this.name)}()`;
|
|
744
704
|
}
|
|
745
705
|
}
|
|
746
|
-
class
|
|
706
|
+
class xe extends W {
|
|
707
|
+
constructor() {
|
|
708
|
+
super("local-first");
|
|
709
|
+
}
|
|
710
|
+
}
|
|
711
|
+
class Se extends W {
|
|
747
712
|
constructor() {
|
|
748
713
|
super("solid");
|
|
749
714
|
}
|
|
@@ -754,10 +719,10 @@ class Se extends U {
|
|
|
754
719
|
await p.run("npm install soukai-solid@next --save-exact"), await p.run("npm install @noeldemartin/solid-utils@next --save-exact"), await p.run("npm install @solid/community-server@7.1.6 --save-dev -E"), await super.installNpmDependencies();
|
|
755
720
|
}
|
|
756
721
|
async updateNpmScripts(e) {
|
|
757
|
-
|
|
722
|
+
o.info("Updating npm scripts...");
|
|
758
723
|
const t = c.read("package.json");
|
|
759
724
|
if (!t)
|
|
760
|
-
return
|
|
725
|
+
return o.fail("Could not find package.json file");
|
|
761
726
|
c.write(
|
|
762
727
|
"package.json",
|
|
763
728
|
t.replace(
|
|
@@ -778,13 +743,13 @@ class Se extends U {
|
|
|
778
743
|
), e.addModifiedFile("package.json");
|
|
779
744
|
}
|
|
780
745
|
async updateGitIgnore() {
|
|
781
|
-
|
|
746
|
+
o.info("Updating .gitignore");
|
|
782
747
|
const e = c.read(".gitignore") ?? "";
|
|
783
748
|
c.write(".gitignore", `${e}/solid
|
|
784
749
|
`);
|
|
785
750
|
}
|
|
786
751
|
}
|
|
787
|
-
class $e extends
|
|
752
|
+
class $e extends W {
|
|
788
753
|
constructor() {
|
|
789
754
|
super("soukai");
|
|
790
755
|
}
|
|
@@ -795,38 +760,38 @@ class $e extends U {
|
|
|
795
760
|
return "soukai({ models: import.meta.glob('@/models/*', { eager: true }) })";
|
|
796
761
|
}
|
|
797
762
|
}
|
|
798
|
-
const
|
|
799
|
-
(
|
|
763
|
+
const R = [new $e(), new Se(), new xe()].reduce(
|
|
764
|
+
(a, e) => Object.assign(a, { [e.name]: e }),
|
|
800
765
|
{}
|
|
801
766
|
);
|
|
802
|
-
class
|
|
767
|
+
class D extends g {
|
|
803
768
|
constructor(t) {
|
|
804
769
|
super();
|
|
805
|
-
|
|
806
|
-
this.plugin =
|
|
770
|
+
r(this, "plugin");
|
|
771
|
+
this.plugin = R[t] ?? o.fail(`Plugin '${t}' doesn't exist. Available plugins: ${Object.keys(R).join(", ")}`);
|
|
807
772
|
}
|
|
808
773
|
async run() {
|
|
809
774
|
await this.plugin.install();
|
|
810
775
|
}
|
|
811
776
|
}
|
|
812
|
-
|
|
777
|
+
r(D, "command", "install"), r(D, "description", "Install an AerogelJS plugin"), r(D, "parameters", [["plugin", "Plugin to install"]]);
|
|
813
778
|
class be {
|
|
814
779
|
run(e) {
|
|
815
780
|
const t = new Z();
|
|
816
|
-
t.name("gel").description("AerogelJS CLI").version(this.getVersion()),
|
|
781
|
+
t.name("gel").description("AerogelJS CLI").version(this.getVersion()), S.define(t), $.define(t), b.define(t), I.define(t), J.define(t), D.define(t), t.parse(e);
|
|
817
782
|
}
|
|
818
783
|
getVersion() {
|
|
819
|
-
const e = "Could not find CLI's version, please report this bug.", t =
|
|
784
|
+
const e = "Could not find CLI's version, please report this bug.", t = k(new x(
|
|
820
785
|
/* @vite-ignore */
|
|
821
786
|
"../package.json",
|
|
822
787
|
import.meta.url
|
|
823
788
|
));
|
|
824
|
-
if (!
|
|
789
|
+
if (!O(t))
|
|
825
790
|
throw new Error(e);
|
|
826
|
-
return JSON.parse(z(t).toString()).version ??
|
|
791
|
+
return JSON.parse(z(t).toString()).version ?? oe(e);
|
|
827
792
|
}
|
|
828
793
|
}
|
|
829
|
-
const Te =
|
|
794
|
+
const Te = C(be);
|
|
830
795
|
export {
|
|
831
796
|
Te as CLI
|
|
832
797
|
};
|