@aerogel/cli 0.0.0-next.44f5953d2450ac149ceabae6448a967b9def9d2a → 0.0.0-next.4b4da752b2ea1e9ee76a4d33a1e616bf87478f69
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 +140 -154
- package/dist/aerogel-cli.js.map +1 -1
- package/package.json +2 -2
- package/src/lib/Editor.ts +0 -1
- package/src/plugins/Plugin.ts +0 -19
- package/src/plugins/Solid.ts +0 -8
- package/templates/app/.vscode/launch.json +1 -0
- package/templates/app/index.html +2 -2
- package/templates/app/package.json +7 -6
- package/templates/app/src/App.vue +1 -1
- package/templates/app/src/assets/css/main.css +4 -3
- package/templates/app/postcss.config.js +0 -6
- package/templates/app/tailwind.config.js +0 -5
- package/templates/postcss-pseudo-classes/postcss.config.js +0 -15
package/dist/aerogel-cli.js
CHANGED
|
@@ -1,17 +1,17 @@
|
|
|
1
|
-
var
|
|
2
|
-
var
|
|
3
|
-
var
|
|
4
|
-
import { Command as
|
|
5
|
-
import { existsSync as N, lstatSync as O, readFileSync as z, readdirSync as
|
|
6
|
-
import { facade as L, stringMatchAll as
|
|
1
|
+
var Q = Object.defineProperty;
|
|
2
|
+
var X = (o, e, t) => e in o ? Q(o, e, { enumerable: !0, configurable: !0, writable: !0, value: t }) : o[e] = t;
|
|
3
|
+
var a = (o, e, t) => X(o, typeof e != "symbol" ? e + "" : e, t);
|
|
4
|
+
import { Command as Z } from "commander";
|
|
5
|
+
import { existsSync as N, lstatSync as O, readFileSync as z, readdirSync as G, mkdirSync as H, writeFileSync as ee } from "node:fs";
|
|
6
|
+
import { facade as L, stringMatchAll as te, toString as ie, stringMatch as se, arrayFrom as I, stringToSlug as T, stringToTitleCase as ne, arrayFilter as ae, stringToStudlyCase as re, formatCodeBlock as M, stringToCamelCase as oe, fail as ce } from "@noeldemartin/utils";
|
|
7
7
|
import { fileURLToPath as x, URL as S } from "node:url";
|
|
8
|
-
import { resolve as J, dirname as W, basename as
|
|
9
|
-
import
|
|
10
|
-
import { cursorTo as
|
|
11
|
-
import
|
|
12
|
-
import { Project as
|
|
13
|
-
import { exec as
|
|
14
|
-
class
|
|
8
|
+
import { resolve as J, dirname as W, basename as le } from "node:path";
|
|
9
|
+
import P from "chalk";
|
|
10
|
+
import { cursorTo as pe, clearLine as de } from "node:readline";
|
|
11
|
+
import ue from "mustache";
|
|
12
|
+
import { Project as ge, SyntaxKind as j, Node as d } from "ts-morph";
|
|
13
|
+
import { exec as me } from "node:child_process";
|
|
14
|
+
class fe {
|
|
15
15
|
contains(e, t) {
|
|
16
16
|
var i;
|
|
17
17
|
return !!((i = this.read(e)) != null && i.includes(t));
|
|
@@ -26,7 +26,7 @@ class he {
|
|
|
26
26
|
return this.isFile(e) ? z(e).toString() : null;
|
|
27
27
|
}
|
|
28
28
|
getFiles(e) {
|
|
29
|
-
const t =
|
|
29
|
+
const t = G(e, { withFileTypes: !0 }), i = [];
|
|
30
30
|
for (const s of t) {
|
|
31
31
|
const n = J(e, s.name);
|
|
32
32
|
s.isDirectory() ? i.push(...this.getFiles(n)) : i.push(n);
|
|
@@ -46,15 +46,15 @@ class he {
|
|
|
46
46
|
H(e, { recursive: !0 });
|
|
47
47
|
}
|
|
48
48
|
write(e, t) {
|
|
49
|
-
N(W(e)) || H(W(e), { recursive: !0 }),
|
|
49
|
+
N(W(e)) || H(W(e), { recursive: !0 }), ee(e, t);
|
|
50
50
|
}
|
|
51
51
|
}
|
|
52
|
-
const c = L(
|
|
53
|
-
class
|
|
52
|
+
const c = L(fe);
|
|
53
|
+
class he {
|
|
54
54
|
constructor() {
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
55
|
+
a(this, "renderInfo", P.hex("#00ffff"));
|
|
56
|
+
a(this, "renderSuccess", P.hex("#00ff00"));
|
|
57
|
+
a(this, "renderError", P.hex("#ff0000"));
|
|
58
58
|
}
|
|
59
59
|
async animate(e, t) {
|
|
60
60
|
const i = (u = "", k = !1) => {
|
|
@@ -81,9 +81,9 @@ class ye {
|
|
|
81
81
|
this.log(this.renderMarkdown(e), this.renderSuccess);
|
|
82
82
|
}
|
|
83
83
|
renderMarkdown(e) {
|
|
84
|
-
const t =
|
|
84
|
+
const t = te(e, /\*\*(.*)\*\*/g);
|
|
85
85
|
for (const i of t)
|
|
86
|
-
e = e.replace(i[0],
|
|
86
|
+
e = e.replace(i[0], P.bold(i[1]));
|
|
87
87
|
return e;
|
|
88
88
|
}
|
|
89
89
|
log(e, t) {
|
|
@@ -106,10 +106,10 @@ class ye {
|
|
|
106
106
|
console.log(e);
|
|
107
107
|
}
|
|
108
108
|
stdout(e) {
|
|
109
|
-
|
|
109
|
+
pe(process.stdout, 0), de(process.stdout, 0), process.stdout.write(e);
|
|
110
110
|
}
|
|
111
111
|
}
|
|
112
|
-
const
|
|
112
|
+
const r = L(he);
|
|
113
113
|
class f {
|
|
114
114
|
constructor(e) {
|
|
115
115
|
this.path = e;
|
|
@@ -122,10 +122,10 @@ class f {
|
|
|
122
122
|
e = `${e}/`.replace(/\/\//, "/");
|
|
123
123
|
for (const n of c.getFiles(this.path)) {
|
|
124
124
|
const l = Object.entries(i).reduce(
|
|
125
|
-
(E, [
|
|
125
|
+
(E, [Y, _]) => E.replaceAll(Y, _),
|
|
126
126
|
n.substring(this.path.length + 1)
|
|
127
127
|
), u = z(n).toString(), k = e + (l.endsWith(".template") ? l.slice(0, -9) : l);
|
|
128
|
-
c.write(k,
|
|
128
|
+
c.write(k, ue.render(u, t, void 0, ["<%", "%>"])), s.push(k);
|
|
129
129
|
}
|
|
130
130
|
return s;
|
|
131
131
|
}
|
|
@@ -134,12 +134,12 @@ class f {
|
|
|
134
134
|
(i, [s, n]) => (typeof n == "object" ? Object.assign(
|
|
135
135
|
i,
|
|
136
136
|
this.getFilenameReplacements(n, `${s}.`)
|
|
137
|
-
) : i[`[${t}${s}]`] =
|
|
137
|
+
) : i[`[${t}${s}]`] = ie(n), i),
|
|
138
138
|
{}
|
|
139
139
|
);
|
|
140
140
|
}
|
|
141
141
|
}
|
|
142
|
-
function
|
|
142
|
+
function ye(o = "") {
|
|
143
143
|
if (c.contains(
|
|
144
144
|
x(new S(
|
|
145
145
|
/* @vite-ignore */
|
|
@@ -159,19 +159,19 @@ function we(o = "") {
|
|
|
159
159
|
"../../../../package.json",
|
|
160
160
|
import.meta.url
|
|
161
161
|
))
|
|
162
|
-
), t =
|
|
162
|
+
), t = se(e ?? "", /"@aerogel\/core": "file:(.*)\/aerogel-core-[\d.]*\.tgz"/), i = (t == null ? void 0 : t[1]) ?? r.fail("Could not determine base path");
|
|
163
163
|
return J(i, o);
|
|
164
164
|
}
|
|
165
165
|
function h(o) {
|
|
166
|
-
return
|
|
166
|
+
return r.fail(`Could not find ${o} pack file, did you run 'npm pack'?`);
|
|
167
167
|
}
|
|
168
168
|
function y(o) {
|
|
169
169
|
return c.getFiles(m(o)).find((e) => e.endsWith(".tgz")) ?? null;
|
|
170
170
|
}
|
|
171
171
|
function m(o) {
|
|
172
|
-
return
|
|
172
|
+
return ye(`../${o}`);
|
|
173
173
|
}
|
|
174
|
-
function
|
|
174
|
+
function w(o) {
|
|
175
175
|
return x(new S(
|
|
176
176
|
/* @vite-ignore */
|
|
177
177
|
`../templates/${o}`,
|
|
@@ -180,14 +180,14 @@ function v(o) {
|
|
|
180
180
|
}
|
|
181
181
|
class ve {
|
|
182
182
|
constructor() {
|
|
183
|
-
|
|
183
|
+
a(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
|
+
me(e, { cwd: this.cwd ?? void 0 }, (s) => {
|
|
191
191
|
if (s) {
|
|
192
192
|
i(s);
|
|
193
193
|
return;
|
|
@@ -198,11 +198,11 @@ class ve {
|
|
|
198
198
|
}
|
|
199
199
|
}
|
|
200
200
|
const p = L(ve);
|
|
201
|
-
class
|
|
201
|
+
class we {
|
|
202
202
|
constructor() {
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
this.project = new
|
|
203
|
+
a(this, "project");
|
|
204
|
+
a(this, "modifiedFiles");
|
|
205
|
+
this.project = new ge({ 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 ke {
|
|
|
211
211
|
return this.project.getSourceFileOrThrow(e);
|
|
212
212
|
}
|
|
213
213
|
async format() {
|
|
214
|
-
await
|
|
214
|
+
await r.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(I(this.modifiedFiles).map(async (n) => s(n)));
|
|
219
219
|
});
|
|
220
220
|
}
|
|
221
221
|
async save(e) {
|
|
@@ -225,12 +225,12 @@ class ke {
|
|
|
225
225
|
this.modifiedFiles.add(e);
|
|
226
226
|
}
|
|
227
227
|
}
|
|
228
|
-
class
|
|
228
|
+
class K {
|
|
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)) && r.fail(`Folder at '${e}' already exists!`), f.instantiate(w("app"), e, {
|
|
234
234
|
app: {
|
|
235
235
|
name: this.name,
|
|
236
236
|
slug: T(this.name)
|
|
@@ -240,7 +240,7 @@ class V {
|
|
|
240
240
|
});
|
|
241
241
|
}
|
|
242
242
|
edit() {
|
|
243
|
-
return new
|
|
243
|
+
return new we();
|
|
244
244
|
}
|
|
245
245
|
getDependencies() {
|
|
246
246
|
const e = (t) => Object.entries(t).reduce(
|
|
@@ -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
|
+
r.fail(`${i} Are you sure this is an Aerogel app?`);
|
|
299
299
|
}
|
|
300
300
|
}
|
|
301
|
-
|
|
301
|
+
a(g, "command", ""), a(g, "description", ""), a(g, "parameters", []), a(g, "options", {});
|
|
302
302
|
class $ extends g {
|
|
303
303
|
constructor(t, i = {}) {
|
|
304
304
|
super();
|
|
305
|
-
|
|
306
|
-
|
|
305
|
+
a(this, "path");
|
|
306
|
+
a(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 ??
|
|
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(le(t));
|
|
311
|
+
p.setWorkingDirectory(t), await this.createApp(i, t), await this.installDependencies(), await this.initializeGit(), r.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
|
+
r.info(`Creating **${t}**...`), new K(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 r.animate("Installing dependencies", async () => {
|
|
329
329
|
await p.run("npm install");
|
|
330
330
|
});
|
|
331
331
|
}
|
|
332
332
|
async initializeGit() {
|
|
333
|
-
await
|
|
333
|
+
await r.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
|
+
a($, "command", "create"), a($, "description", "Create AerogelJS app"), a($, "parameters", [["path", "Application path"]]), a($, "options", {
|
|
339
339
|
name: "Application name",
|
|
340
340
|
local: {
|
|
341
341
|
type: "boolean",
|
|
@@ -347,18 +347,18 @@ r($, "command", "create"), r($, "description", "Create AerogelJS app"), r($, "pa
|
|
|
347
347
|
}
|
|
348
348
|
});
|
|
349
349
|
function q() {
|
|
350
|
-
return new
|
|
350
|
+
return new K("");
|
|
351
351
|
}
|
|
352
|
-
function
|
|
352
|
+
function ke() {
|
|
353
353
|
return c.contains("package.json", '"@aerogel/core": "file:');
|
|
354
354
|
}
|
|
355
|
-
function
|
|
355
|
+
function xe() {
|
|
356
356
|
return c.isSymlink("node_modules/@aerogel/core");
|
|
357
357
|
}
|
|
358
|
-
function
|
|
358
|
+
function v(o, e = {}) {
|
|
359
359
|
if (!o)
|
|
360
360
|
return;
|
|
361
|
-
const t = e.guard ?? (() => !0), i = e.validate ?? (() => !0), s =
|
|
361
|
+
const t = e.guard ?? (() => !0), i = e.validate ?? (() => !0), s = I(e.skip ?? []);
|
|
362
362
|
return o.forEachDescendant((n, l) => {
|
|
363
363
|
if (t(n) && i(n))
|
|
364
364
|
return n;
|
|
@@ -373,34 +373,34 @@ function R(o, e) {
|
|
|
373
373
|
class b extends g {
|
|
374
374
|
constructor(t, i = {}) {
|
|
375
375
|
super();
|
|
376
|
-
|
|
377
|
-
|
|
376
|
+
a(this, "path");
|
|
377
|
+
a(this, "options");
|
|
378
378
|
this.path = t, this.options = i;
|
|
379
379
|
}
|
|
380
380
|
async validate() {
|
|
381
|
-
|
|
381
|
+
ae([this.options.button, this.options.input, this.options.checkbox]).length > 1 && r.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 = I(t).map((l) => `- ${l}`).join(`
|
|
388
388
|
`);
|
|
389
|
-
|
|
389
|
+
r.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"') && r.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 r.animate("Creating component", async () => {
|
|
401
|
+
c.exists(`src/components/${this.path}.vue`) && r.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
|
-
f.instantiate(
|
|
403
|
+
f.instantiate(w(n), `src/components/${t}`, {
|
|
404
404
|
component: {
|
|
405
405
|
name: i,
|
|
406
406
|
slug: T(i)
|
|
@@ -409,9 +409,9 @@ ${n}`);
|
|
|
409
409
|
});
|
|
410
410
|
}
|
|
411
411
|
async createStory(t, i, s) {
|
|
412
|
-
this.options.story && await
|
|
412
|
+
this.options.story && await r.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
|
-
f.instantiate(
|
|
414
|
+
f.instantiate(w(n), `src/components/${t}`, {
|
|
415
415
|
component: {
|
|
416
416
|
name: i,
|
|
417
417
|
slug: T(i)
|
|
@@ -422,27 +422,27 @@ ${n}`);
|
|
|
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 r.fail("Could not find component dirs declaration in vite config!");
|
|
426
|
+
s.getDescendantsOfKind(j.StringLiteral).some((n) => n.getText() === "'src/components'") || (await r.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 =
|
|
431
|
+
const i = v(t, {
|
|
432
432
|
guard: d.isCallExpression,
|
|
433
433
|
validate: (l) => l.getText().startsWith("Components("),
|
|
434
|
-
skip:
|
|
434
|
+
skip: j.ImportDeclaration
|
|
435
435
|
});
|
|
436
436
|
if (!i)
|
|
437
437
|
return null;
|
|
438
|
-
const s =
|
|
438
|
+
const s = v(i, {
|
|
439
439
|
guard: d.isPropertyAssignment,
|
|
440
440
|
validate: (l) => l.getName() === "dirs"
|
|
441
441
|
}), n = s == null ? void 0 : s.getInitializer();
|
|
442
442
|
return d.isArrayLiteralExpression(n) ? n : this.declareComponentDirsArray(i);
|
|
443
443
|
}
|
|
444
444
|
declareComponentDirsArray(t) {
|
|
445
|
-
const i =
|
|
445
|
+
const i = v(t, { guard: d.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
|
+
a(b, "command", "generate:component"), a(b, "description", "Generate an AerogelJS Component"), a(b, "parameters", [
|
|
457
457
|
["path", "Component path (relative to components folder; extension not necessary)"]
|
|
458
|
-
]),
|
|
458
|
+
]), a(b, "options", {
|
|
459
459
|
button: {
|
|
460
460
|
description: "Create a custom button",
|
|
461
461
|
type: "boolean"
|
|
@@ -473,16 +473,16 @@ r(b, "command", "generate:component"), r(b, "description", "Generate an AerogelJ
|
|
|
473
473
|
type: "boolean"
|
|
474
474
|
}
|
|
475
475
|
});
|
|
476
|
-
class
|
|
476
|
+
class F extends g {
|
|
477
477
|
constructor(t, i = {}) {
|
|
478
478
|
super();
|
|
479
|
-
|
|
480
|
-
|
|
479
|
+
a(this, "name");
|
|
480
|
+
a(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`) && r.fail(`${this.name} model already exists!`), this.assertSoukaiInstalled();
|
|
485
|
+
const t = await r.animate("Creating model", async () => f.instantiate(w("model"), "src/models", {
|
|
486
486
|
model: {
|
|
487
487
|
name: this.name,
|
|
488
488
|
fieldsDefinition: this.getFieldsDefinition()
|
|
@@ -490,7 +490,7 @@ class j extends g {
|
|
|
490
490
|
soukaiImports: this.options.fields ? "FieldType, defineModelSchema" : "defineModelSchema"
|
|
491
491
|
}).map((s) => `- ${s}`).join(`
|
|
492
492
|
`));
|
|
493
|
-
|
|
493
|
+
r.info(`${this.name} model created successfully! The following files were created:
|
|
494
494
|
|
|
495
495
|
${t}`);
|
|
496
496
|
}
|
|
@@ -501,7 +501,7 @@ ${t}`);
|
|
|
501
501
|
const [s, n, l] = i.split(":");
|
|
502
502
|
return {
|
|
503
503
|
name: s,
|
|
504
|
-
type:
|
|
504
|
+
type: re(n ?? "string"),
|
|
505
505
|
required: l === "required"
|
|
506
506
|
};
|
|
507
507
|
}).reduce((i, s) => {
|
|
@@ -517,74 +517,74 @@ ${n},`;
|
|
|
517
517
|
return M(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"') && r.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
|
+
a(F, "command", "generate:model"), a(F, "description", "Generate an AerogelJS Model"), a(F, "parameters", [["name", "Model name"]]), a(F, "options", {
|
|
527
527
|
fields: "Create model with the given fields"
|
|
528
528
|
});
|
|
529
|
-
class
|
|
529
|
+
class D extends g {
|
|
530
530
|
constructor(t = {}) {
|
|
531
531
|
super();
|
|
532
|
-
|
|
532
|
+
a(this, "options");
|
|
533
533
|
this.options = t;
|
|
534
534
|
}
|
|
535
535
|
async run() {
|
|
536
536
|
this.assertAerogelOrDirectory("src/components"), this.assertHistoireInstalled();
|
|
537
537
|
const t = /* @__PURE__ */ new Set();
|
|
538
538
|
await this.createComponents(t), await this.createStory(t);
|
|
539
|
-
const i =
|
|
539
|
+
const i = I(t).map((s) => `- ${s}`).join(`
|
|
540
540
|
`);
|
|
541
|
-
|
|
541
|
+
r.info(`Overrides created successfully! The following files were created:
|
|
542
542
|
|
|
543
|
-
${i}`),
|
|
543
|
+
${i}`), r.info(`
|
|
544
544
|
Remember to declare your components in main.ts and main.histoire.ts!`);
|
|
545
545
|
}
|
|
546
546
|
assertHistoireInstalled() {
|
|
547
|
-
this.options.story && !c.contains("package.json", '"histoire"') && !c.contains("package.json", '"@aerogel/histoire"') &&
|
|
547
|
+
this.options.story && !c.contains("package.json", '"histoire"') && !c.contains("package.json", '"@aerogel/histoire"') && r.fail(`
|
|
548
548
|
Histoire is not installed yet! You can install it running:
|
|
549
549
|
npx gel install histoire
|
|
550
550
|
`);
|
|
551
551
|
}
|
|
552
552
|
async createComponents(t) {
|
|
553
|
-
await
|
|
554
|
-
c.exists("src/components/ModalWrapper.vue") &&
|
|
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
555
|
});
|
|
556
556
|
}
|
|
557
557
|
async createStory(t) {
|
|
558
|
-
this.options.story && await
|
|
559
|
-
f.instantiate(
|
|
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
560
|
});
|
|
561
561
|
}
|
|
562
562
|
}
|
|
563
|
-
|
|
563
|
+
a(D, "command", "generate:overrides"), a(D, "description", "Generate AerogelJS component overrides"), a(D, "options", {
|
|
564
564
|
story: {
|
|
565
565
|
description: "Create overrides story using Histoire",
|
|
566
566
|
type: "boolean"
|
|
567
567
|
}
|
|
568
568
|
});
|
|
569
|
-
class
|
|
569
|
+
class C extends g {
|
|
570
570
|
constructor(t) {
|
|
571
571
|
super();
|
|
572
|
-
|
|
572
|
+
a(this, "name");
|
|
573
573
|
this.name = t;
|
|
574
574
|
}
|
|
575
575
|
async run() {
|
|
576
576
|
this.assertAerogelOrDirectory("src/services");
|
|
577
577
|
const t = /* @__PURE__ */ new Set(), i = q().edit();
|
|
578
578
|
await this.createService(t), await this.registerService(i), await i.format();
|
|
579
|
-
const s =
|
|
579
|
+
const s = I(t).map((n) => `- ${n}`).join(`
|
|
580
580
|
`);
|
|
581
|
-
|
|
581
|
+
r.info(`${this.name} service created successfully! The following files were created:
|
|
582
582
|
|
|
583
583
|
${s}`);
|
|
584
584
|
}
|
|
585
585
|
async createService(t) {
|
|
586
|
-
await
|
|
587
|
-
c.exists(`src/services/${this.name}.ts`) &&
|
|
586
|
+
await r.animate("Creating service", async () => {
|
|
587
|
+
c.exists(`src/services/${this.name}.ts`) && r.fail(`${this.name} service already exists!`), f.instantiate(w("service"), "src/services", {
|
|
588
588
|
service: {
|
|
589
589
|
name: this.name
|
|
590
590
|
}
|
|
@@ -592,16 +592,16 @@ ${s}`);
|
|
|
592
592
|
});
|
|
593
593
|
}
|
|
594
594
|
async registerService(t) {
|
|
595
|
-
await
|
|
595
|
+
await r.animate("Registering service", async () => {
|
|
596
596
|
c.exists("src/services/index.ts") || await this.createServicesIndex(t);
|
|
597
597
|
const i = t.requireSourceFile("src/services/index.ts"), s = this.getServicesObject(i);
|
|
598
598
|
if (!s)
|
|
599
|
-
return
|
|
599
|
+
return r.fail("Could not find services object in services config, please add it manually.");
|
|
600
600
|
i.addImportDeclaration({
|
|
601
601
|
defaultImport: this.name,
|
|
602
602
|
moduleSpecifier: `./${this.name}`
|
|
603
603
|
}), s.addPropertyAssignment({
|
|
604
|
-
name: `$${
|
|
604
|
+
name: `$${oe(this.name)}`,
|
|
605
605
|
initializer: this.name
|
|
606
606
|
}), await t.save(i);
|
|
607
607
|
});
|
|
@@ -621,42 +621,42 @@ ${s}`);
|
|
|
621
621
|
), t.addSourceFile("src/services/index.ts");
|
|
622
622
|
const i = t.requireSourceFile("src/main.ts"), s = this.getBootstrapOptions(i);
|
|
623
623
|
if (!s)
|
|
624
|
-
return
|
|
624
|
+
return r.fail("Could not find options object in bootstrap config, please add the services manually.");
|
|
625
625
|
s.insertShorthandPropertyAssignment(0, { name: "services" }), i.addImportDeclaration({
|
|
626
626
|
namedImports: ["services"],
|
|
627
627
|
moduleSpecifier: "./services"
|
|
628
628
|
}), await t.save(i);
|
|
629
629
|
}
|
|
630
630
|
getBootstrapOptions(t) {
|
|
631
|
-
const i =
|
|
631
|
+
const i = v(t, {
|
|
632
632
|
guard: d.isCallExpression,
|
|
633
633
|
validate: (n) => n.getExpression().getText() === "bootstrap",
|
|
634
|
-
skip:
|
|
634
|
+
skip: j.ImportDeclaration
|
|
635
635
|
}), s = i == null ? void 0 : i.getArguments()[1];
|
|
636
636
|
return d.isObjectLiteralExpression(s) ? s : null;
|
|
637
637
|
}
|
|
638
638
|
getServicesObject(t) {
|
|
639
|
-
const i =
|
|
639
|
+
const i = v(t, {
|
|
640
640
|
guard: d.isVariableDeclaration,
|
|
641
641
|
validate: (n) => n.getName() === "services"
|
|
642
642
|
}), s = i == null ? void 0 : i.getInitializer();
|
|
643
643
|
return d.isObjectLiteralExpression(s) ? s : null;
|
|
644
644
|
}
|
|
645
645
|
}
|
|
646
|
-
|
|
646
|
+
a(C, "command", "generate:service"), a(C, "description", "Generate an AerogelJS Service"), a(C, "parameters", [["name", "Service name"]]);
|
|
647
647
|
class B extends g {
|
|
648
648
|
async run() {
|
|
649
|
-
|
|
649
|
+
r.info("[AerogelJS CLI info]"), r.info("Installation directory: " + x(new S(
|
|
650
650
|
/* @vite-ignore */
|
|
651
651
|
"./",
|
|
652
652
|
import.meta.url
|
|
653
653
|
)));
|
|
654
654
|
}
|
|
655
655
|
}
|
|
656
|
-
|
|
657
|
-
class
|
|
656
|
+
a(B, "command", "info"), a(B, "description", "Show debugging information about the CLI");
|
|
657
|
+
class U {
|
|
658
658
|
constructor(e) {
|
|
659
|
-
|
|
659
|
+
a(this, "name");
|
|
660
660
|
this.name = e;
|
|
661
661
|
}
|
|
662
662
|
async install() {
|
|
@@ -665,17 +665,17 @@ class Y {
|
|
|
665
665
|
const e = q().edit();
|
|
666
666
|
await this.updateFiles(e), await e.format();
|
|
667
667
|
}
|
|
668
|
-
await this.afterInstall(),
|
|
668
|
+
await this.afterInstall(), r.info(`Plugin ${this.name} installed!`);
|
|
669
669
|
}
|
|
670
670
|
assertNotInstalled() {
|
|
671
|
-
c.contains("package.json", `"${this.getNpmPackageName()}"`) &&
|
|
671
|
+
c.contains("package.json", `"${this.getNpmPackageName()}"`) && r.fail(`${this.name} is already installed!`);
|
|
672
672
|
}
|
|
673
673
|
async beforeInstall() {
|
|
674
674
|
}
|
|
675
675
|
async afterInstall() {
|
|
676
676
|
}
|
|
677
677
|
async installDependencies() {
|
|
678
|
-
await
|
|
678
|
+
await r.animate("Installing plugin dependencies", async () => {
|
|
679
679
|
await this.installNpmDependencies();
|
|
680
680
|
});
|
|
681
681
|
}
|
|
@@ -684,11 +684,11 @@ class Y {
|
|
|
684
684
|
}
|
|
685
685
|
async installNpmDependencies() {
|
|
686
686
|
const e = this.isForDevelopment() ? "--save-dev" : "";
|
|
687
|
-
if (
|
|
687
|
+
if (xe()) {
|
|
688
688
|
await p.run(`npm install file:${m(this.getLocalPackageName())} ${e}`);
|
|
689
689
|
return;
|
|
690
690
|
}
|
|
691
|
-
if (
|
|
691
|
+
if (ke()) {
|
|
692
692
|
const t = y(this.getLocalPackageName()) ?? h(this.getLocalPackageName());
|
|
693
693
|
await p.run(`npm install file:${t} ${e}`);
|
|
694
694
|
return;
|
|
@@ -696,10 +696,10 @@ class Y {
|
|
|
696
696
|
await p.run(`npm install ${this.getNpmPackageName()}@next --save-exact ${e}`);
|
|
697
697
|
}
|
|
698
698
|
async updateBootstrapConfig(e) {
|
|
699
|
-
await
|
|
699
|
+
await r.animate("Injecting plugin in bootstrap configuration", async () => {
|
|
700
700
|
const t = e.requireSourceFile("src/main.ts"), i = this.getBootstrapPluginsDeclaration(t);
|
|
701
701
|
if (!i)
|
|
702
|
-
return
|
|
702
|
+
return r.fail(`
|
|
703
703
|
Could not find plugins array in bootstrap config, please add the following manually:
|
|
704
704
|
|
|
705
705
|
${this.getBootstrapConfig()}
|
|
@@ -707,32 +707,20 @@ class Y {
|
|
|
707
707
|
t.addImportDeclaration(this.getBootstrapImport()), i.addElement(this.getBootstrapConfig()), await e.save(t);
|
|
708
708
|
});
|
|
709
709
|
}
|
|
710
|
-
async updateTailwindConfig(e, t) {
|
|
711
|
-
await a.animate("Updating tailwind configuration", async () => {
|
|
712
|
-
const i = e.requireSourceFile("tailwind.config.js"), s = this.getTailwindContentArray(i);
|
|
713
|
-
if (!s)
|
|
714
|
-
return a.fail(`
|
|
715
|
-
Could not find content array in tailwind config, please add the following manually:
|
|
716
|
-
|
|
717
|
-
${t.content}
|
|
718
|
-
`);
|
|
719
|
-
s.addElement(t.content), await e.save(i);
|
|
720
|
-
});
|
|
721
|
-
}
|
|
722
710
|
getBootstrapPluginsDeclaration(e) {
|
|
723
711
|
var l, u;
|
|
724
|
-
const t =
|
|
712
|
+
const t = v(e, {
|
|
725
713
|
guard: d.isCallExpression,
|
|
726
714
|
validate: (k) => k.getExpression().getText() === "bootstrap",
|
|
727
|
-
skip:
|
|
715
|
+
skip: j.ImportDeclaration
|
|
728
716
|
}), i = t == null ? void 0 : t.getArguments()[1], s = (l = R(i, d.isObjectLiteralExpression)) == null ? void 0 : l.getProperty("plugins"), n = (u = R(s, d.isPropertyAssignment)) == null ? void 0 : u.getInitializer();
|
|
729
717
|
return d.isArrayLiteralExpression(n) ? n : null;
|
|
730
718
|
}
|
|
731
719
|
getTailwindContentArray(e) {
|
|
732
|
-
const t =
|
|
720
|
+
const t = v(e, {
|
|
733
721
|
guard: d.isPropertyAssignment,
|
|
734
722
|
validate: (s) => s.getName() === "content",
|
|
735
|
-
skip:
|
|
723
|
+
skip: j.JSDoc
|
|
736
724
|
}), i = t == null ? void 0 : t.getInitializer();
|
|
737
725
|
return d.isArrayLiteralExpression(i) ? i : null;
|
|
738
726
|
}
|
|
@@ -755,23 +743,21 @@ class Y {
|
|
|
755
743
|
return `${this.name}()`;
|
|
756
744
|
}
|
|
757
745
|
}
|
|
758
|
-
class Se extends
|
|
746
|
+
class Se extends U {
|
|
759
747
|
constructor() {
|
|
760
748
|
super("solid");
|
|
761
749
|
}
|
|
762
750
|
async updateFiles(e) {
|
|
763
|
-
await this.
|
|
764
|
-
content: K() ? `'${m("plugin-solid")}/dist/**/*.js'` : "'./node_modules/@aerogel/plugin-solid/dist/**/*.js'"
|
|
765
|
-
}), await this.updateNpmScripts(e), await this.updateGitIgnore(), await super.updateFiles(e);
|
|
751
|
+
await this.updateNpmScripts(e), await this.updateGitIgnore(), await super.updateFiles(e);
|
|
766
752
|
}
|
|
767
753
|
async installNpmDependencies() {
|
|
768
754
|
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();
|
|
769
755
|
}
|
|
770
756
|
async updateNpmScripts(e) {
|
|
771
|
-
|
|
757
|
+
r.info("Updating npm scripts...");
|
|
772
758
|
const t = c.read("package.json");
|
|
773
759
|
if (!t)
|
|
774
|
-
return
|
|
760
|
+
return r.fail("Could not find package.json file");
|
|
775
761
|
c.write(
|
|
776
762
|
"package.json",
|
|
777
763
|
t.replace(
|
|
@@ -792,13 +778,13 @@ class Se extends Y {
|
|
|
792
778
|
), e.addModifiedFile("package.json");
|
|
793
779
|
}
|
|
794
780
|
async updateGitIgnore() {
|
|
795
|
-
|
|
781
|
+
r.info("Updating .gitignore");
|
|
796
782
|
const e = c.read(".gitignore") ?? "";
|
|
797
783
|
c.write(".gitignore", `${e}/solid
|
|
798
784
|
`);
|
|
799
785
|
}
|
|
800
786
|
}
|
|
801
|
-
class $e extends
|
|
787
|
+
class $e extends U {
|
|
802
788
|
constructor() {
|
|
803
789
|
super("soukai");
|
|
804
790
|
}
|
|
@@ -809,25 +795,25 @@ class $e extends Y {
|
|
|
809
795
|
return "soukai({ models: import.meta.glob('@/models/*', { eager: true }) })";
|
|
810
796
|
}
|
|
811
797
|
}
|
|
812
|
-
const
|
|
798
|
+
const V = [new $e(), new Se()].reduce(
|
|
813
799
|
(o, e) => Object.assign(o, { [e.name]: e }),
|
|
814
800
|
{}
|
|
815
801
|
);
|
|
816
|
-
class
|
|
802
|
+
class A extends g {
|
|
817
803
|
constructor(t) {
|
|
818
804
|
super();
|
|
819
|
-
|
|
820
|
-
this.plugin =
|
|
805
|
+
a(this, "plugin");
|
|
806
|
+
this.plugin = V[t] ?? r.fail(`Plugin '${t}' doesn't exist. Available plugins: ${Object.keys(V).join(", ")}`);
|
|
821
807
|
}
|
|
822
808
|
async run() {
|
|
823
809
|
await this.plugin.install();
|
|
824
810
|
}
|
|
825
811
|
}
|
|
826
|
-
|
|
812
|
+
a(A, "command", "install"), a(A, "description", "Install an AerogelJS plugin"), a(A, "parameters", [["plugin", "Plugin to install"]]);
|
|
827
813
|
class be {
|
|
828
814
|
run(e) {
|
|
829
|
-
const t = new
|
|
830
|
-
t.name("gel").description("AerogelJS CLI").version(this.getVersion()), $.define(t), b.define(t),
|
|
815
|
+
const t = new Z();
|
|
816
|
+
t.name("gel").description("AerogelJS CLI").version(this.getVersion()), $.define(t), b.define(t), F.define(t), D.define(t), C.define(t), B.define(t), A.define(t), t.parse(e);
|
|
831
817
|
}
|
|
832
818
|
getVersion() {
|
|
833
819
|
const e = "Could not find CLI's version, please report this bug.", t = x(new S(
|
|
@@ -837,7 +823,7 @@ class be {
|
|
|
837
823
|
));
|
|
838
824
|
if (!N(t))
|
|
839
825
|
throw new Error(e);
|
|
840
|
-
return JSON.parse(z(t).toString()).version ??
|
|
826
|
+
return JSON.parse(z(t).toString()).version ?? ce(e);
|
|
841
827
|
}
|
|
842
828
|
}
|
|
843
829
|
const Te = L(be);
|