@aerogel/cli 0.0.0-next.c2e6acc000e97a1020c2e232678563c53884dd0e → 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.
@@ -1,26 +1,26 @@
1
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);
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 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
- import { fileURLToPath as x, URL as S } from "node:url";
8
- import { resolve as J, dirname as W, basename as le } from "node:path";
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 pe, clearLine as de } from "node:readline";
10
+ import { cursorTo as le, clearLine as pe } from "node:readline";
11
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 {
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 N(e);
20
+ return O(e);
21
21
  }
22
22
  isSymlink(e) {
23
- return O(e).isSymbolicLink();
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 = J(e, s.name);
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) && O(e).isDirectory();
37
+ return this.exists(e) && E(e).isDirectory();
38
38
  }
39
39
  isFile(e) {
40
- return this.exists(e) && O(e).isFile();
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
- H(e, { recursive: !0 });
46
+ V(e, { recursive: !0 });
47
47
  }
48
48
  write(e, t) {
49
- N(W(e)) || H(W(e), { recursive: !0 }), ee(e, t);
49
+ O(H(e)) || V(H(e), { recursive: !0 }), ee(e, t);
50
50
  }
51
51
  }
52
- const c = L(fe);
53
- class he {
52
+ const c = C(me);
53
+ class fe {
54
54
  constructor() {
55
- a(this, "renderInfo", P.hex("#00ffff"));
56
- a(this, "renderSuccess", P.hex("#00ff00"));
57
- a(this, "renderError", P.hex("#ff0000"));
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 = (u = "", k = !1) => {
61
- const E = this.renderInfo(this.renderMarkdown(e) + (k ? "..." : ".".repeat(s % 4))) + u;
62
- this.stdout(E);
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
- pe(process.stdout, 0), de(process.stdout, 0), process.stdout.write(e);
109
+ le(process.stdout, 0), pe(process.stdout, 0), process.stdout.write(e);
110
110
  }
111
111
  }
112
- const r = L(he);
113
- class f {
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 f(e).instantiate(t, i);
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
- (E, [Y, _]) => E.replaceAll(Y, _),
125
+ (L, [Y, _]) => L.replaceAll(Y, _),
126
126
  n.substring(this.path.length + 1)
127
- ), u = z(n).toString(), k = e + (l.endsWith(".template") ? l.slice(0, -9) : l);
128
- c.write(k, ue.render(u, t, void 0, ["<%", "%>"])), s.push(k);
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 ye(o = "") {
142
+ function he(a = "") {
143
143
  if (c.contains(
144
- x(new S(
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 J(x(new S(
151
+ return B(k(new x(
152
152
  /* @vite-ignore */
153
153
  "../",
154
154
  import.meta.url
155
- )), o);
155
+ )), a);
156
156
  const e = c.read(
157
- x(new S(
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]) ?? r.fail("Could not determine base path");
163
- return J(i, o);
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 h(o) {
166
- return r.fail(`Could not find ${o} pack file, did you run 'npm pack'?`);
165
+ function f(a) {
166
+ return o.fail(`Could not find ${a} pack file, did you run 'npm pack'?`);
167
167
  }
168
- function y(o) {
169
- return c.getFiles(m(o)).find((e) => e.endsWith(".tgz")) ?? null;
168
+ function h(a) {
169
+ return c.getFiles(m(a)).find((e) => e.endsWith(".tgz")) ?? null;
170
170
  }
171
- function m(o) {
172
- return ye(`../${o}`);
171
+ function m(a) {
172
+ return he(`../${a}`);
173
173
  }
174
- function w(o) {
175
- return x(new S(
174
+ function j(a) {
175
+ return k(new x(
176
176
  /* @vite-ignore */
177
- `../templates/${o}`,
177
+ `../templates/${a}`,
178
178
  import.meta.url
179
179
  ));
180
180
  }
181
- class ve {
181
+ class ye {
182
182
  constructor() {
183
- a(this, "cwd", null);
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
- me(e, { cwd: this.cwd ?? void 0 }, (s) => {
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 = L(ve);
201
- class we {
200
+ const p = C(ye);
201
+ class ve {
202
202
  constructor() {
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");
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 r.animate("Formatting modified files", async () => {
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(I(this.modifiedFiles).map(async (n) => s(n)));
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 K {
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)) && r.fail(`Folder at '${e}' already exists!`), f.instantiate(w("app"), 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: T(this.name)
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 we();
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: y("cli") ?? h("cli"),
259
- aerogelCore: y("core") ?? h("core"),
260
- aerogelCypress: y("cypress") ?? h("cypress"),
261
- aerogelPluginI18n: y("plugin-i18n") ?? h("plugin-i18n"),
262
- aerogelPluginSoukai: y("plugin-soukai") ?? h("plugin-soukai"),
263
- aerogelVite: y("vite") ?? h("vite")
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
- r.fail(`${i} Are you sure this is an Aerogel app?`);
298
+ o.fail(`${i} Are you sure this is an Aerogel app?`);
299
299
  }
300
300
  }
301
- a(g, "command", ""), a(g, "description", ""), a(g, "parameters", []), a(g, "options", {});
302
- class $ extends g {
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
- a(this, "path");
306
- a(this, "options");
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(le(t));
311
- p.setWorkingDirectory(t), await this.createApp(i, t), await this.installDependencies(), await this.initializeGit(), r.success(`
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
- r.info(`Creating **${t}**...`), new K(t, {
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 r.animate("Installing dependencies", async () => {
328
+ await o.animate("Installing dependencies", async () => {
329
329
  await p.run("npm install");
330
330
  });
331
331
  }
332
332
  async initializeGit() {
333
- await r.animate("Initializing git", async () => {
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
- a($, "command", "create"), a($, "description", "Create AerogelJS app"), a($, "parameters", [["path", "Application path"]]), a($, "options", {
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 K("");
350
+ return new U("");
351
351
  }
352
- function ke() {
352
+ function we() {
353
353
  return c.contains("package.json", '"@aerogel/core": "file:');
354
354
  }
355
- function xe() {
355
+ function ke() {
356
356
  return c.isSymlink("node_modules/@aerogel/core");
357
357
  }
358
- function v(o, e = {}) {
359
- if (!o)
358
+ function y(a, e = {}) {
359
+ if (!a)
360
360
  return;
361
- const t = e.guard ?? (() => !0), i = e.validate ?? (() => !0), s = I(e.skip ?? []);
362
- return o.forEachDescendant((n, l) => {
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 u = n.getKind();
366
- s.includes(u) && l.skip();
365
+ const d = n.getKind();
366
+ s.includes(d) && l.skip();
367
367
  });
368
368
  }
369
- function R(o, e) {
370
- if (!(!o || !e(o)))
371
- return o;
369
+ function K(a, e) {
370
+ if (!(!a || !e(a)))
371
+ return a;
372
372
  }
373
- class b extends g {
373
+ class $ extends g {
374
374
  constructor(t, i = {}) {
375
375
  super();
376
- a(this, "path");
377
- a(this, "options");
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 && r.fail("Can only use one of 'button', 'input', or 'checkbox' flags!");
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 = I(t).map((l) => `- ${l}`).join(`
387
+ const n = A(t).map((l) => `- ${l}`).join(`
388
388
  `);
389
- r.info(`${s} component created successfully! The following files were created:
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"') && r.fail(`
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 r.animate("Creating component", async () => {
401
- c.exists(`src/components/${this.path}.vue`) && r.fail(`${this.path} component already exists!`);
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
- f.instantiate(w(n), `src/components/${t}`, {
403
+ v.instantiate(j(n), `src/components/${t}`, {
404
404
  component: {
405
405
  name: i,
406
- slug: T(i)
406
+ slug: N(i)
407
407
  }
408
- }).forEach((u) => s.add(u));
408
+ }).forEach((d) => s.add(d));
409
409
  });
410
410
  }
411
411
  async createStory(t, i, s) {
412
- this.options.story && await r.animate("Creating story", async () => {
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
- f.instantiate(w(n), `src/components/${t}`, {
414
+ v.instantiate(j(n), `src/components/${t}`, {
415
415
  component: {
416
416
  name: i,
417
- slug: T(i)
417
+ slug: N(i)
418
418
  }
419
- }).forEach((u) => s.add(u));
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 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 () => {
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 = v(t, {
432
- guard: d.isCallExpression,
431
+ const i = y(t, {
432
+ guard: u.isCallExpression,
433
433
  validate: (l) => l.getText().startsWith("Components("),
434
- skip: j.ImportDeclaration
434
+ skip: F.ImportDeclaration
435
435
  });
436
436
  if (!i)
437
437
  return null;
438
- const s = v(i, {
439
- guard: d.isPropertyAssignment,
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 d.isArrayLiteralExpression(n) ? n : this.declareComponentDirsArray(i);
442
+ return u.isArrayLiteralExpression(n) ? n : this.declareComponentDirsArray(i);
443
443
  }
444
444
  declareComponentDirsArray(t) {
445
- const i = v(t, { guard: d.isObjectLiteralExpression }), s = i == null ? void 0 : i.addPropertyAssignment({
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
- a(b, "command", "generate:component"), a(b, "description", "Generate an AerogelJS Component"), a(b, "parameters", [
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
- ]), a(b, "options", {
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 F extends g {
476
+ class b extends g {
477
477
  constructor(t, i = {}) {
478
478
  super();
479
- a(this, "name");
480
- a(this, "options");
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`) && r.fail(`${this.name} model already exists!`), this.assertSoukaiInstalled();
485
- const t = await r.animate("Creating model", async () => f.instantiate(w("model"), "src/models", {
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
- r.info(`${this.name} model created successfully! The following files were created:
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 ? M(`
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 M(t, { indent: 8 });
517
+ return T(t, { indent: 8 });
518
518
  }
519
519
  assertSoukaiInstalled() {
520
- !c.contains("package.json", '"soukai"') && !c.contains("package.json", '"@aerogel/plugin-soukai"') && r.fail(`
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
- a(F, "command", "generate:model"), a(F, "description", "Generate an AerogelJS Model"), a(F, "parameters", [["name", "Model name"]]), a(F, "options", {
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 D extends g {
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
- a(this, "name");
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 = I(t).map((n) => `- ${n}`).join(`
539
+ const s = A(t).map((n) => `- ${n}`).join(`
580
540
  `);
581
- r.info(`${this.name} service created successfully! The following files were created:
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 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", {
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 r.animate("Registering service", async () => {
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 r.fail("Could not find services object in services config, please add it manually.");
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: `$${oe(this.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
- M(`
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 r.fail("Could not find options object in bootstrap config, please add the services manually.");
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 = v(t, {
632
- guard: d.isCallExpression,
591
+ const i = y(t, {
592
+ guard: u.isCallExpression,
633
593
  validate: (n) => n.getExpression().getText() === "bootstrap",
634
- skip: j.ImportDeclaration
594
+ skip: F.ImportDeclaration
635
595
  }), s = i == null ? void 0 : i.getArguments()[1];
636
- return d.isObjectLiteralExpression(s) ? s : null;
596
+ return u.isObjectLiteralExpression(s) ? s : null;
637
597
  }
638
598
  getServicesObject(t) {
639
- const i = v(t, {
640
- guard: d.isVariableDeclaration,
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 d.isObjectLiteralExpression(s) ? s : null;
603
+ return u.isObjectLiteralExpression(s) ? s : null;
644
604
  }
645
605
  }
646
- a(C, "command", "generate:service"), a(C, "description", "Generate an AerogelJS Service"), a(C, "parameters", [["name", "Service name"]]);
647
- class B extends g {
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
- r.info("[AerogelJS CLI info]"), r.info("Installation directory: " + x(new S(
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
- a(B, "command", "info"), a(B, "description", "Show debugging information about the CLI");
657
- class U {
616
+ r(J, "command", "info"), r(J, "description", "Show debugging information about the CLI");
617
+ class W {
658
618
  constructor(e) {
659
- a(this, "name");
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(), r.info(`Plugin ${this.name} installed!`);
628
+ await this.afterInstall(), o.info(`Plugin ${this.name} installed!`);
669
629
  }
670
630
  assertNotInstalled() {
671
- c.contains("package.json", `"${this.getNpmPackageName()}"`) && r.fail(`${this.name} is already installed!`);
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 r.animate("Installing plugin dependencies", async () => {
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 (xe()) {
647
+ if (ke()) {
688
648
  await p.run(`npm install file:${m(this.getLocalPackageName())} ${e}`);
689
649
  return;
690
650
  }
691
- if (ke()) {
692
- const t = y(this.getLocalPackageName()) ?? h(this.getLocalPackageName());
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 r.animate("Injecting plugin in bootstrap configuration", async () => {
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 r.fail(`
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, u;
712
- const t = v(e, {
713
- guard: d.isCallExpression,
714
- validate: (k) => k.getExpression().getText() === "bootstrap",
715
- skip: j.ImportDeclaration
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();
717
- return d.isArrayLiteralExpression(n) ? n : null;
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 = v(e, {
721
- guard: d.isPropertyAssignment,
680
+ const t = y(e, {
681
+ guard: u.isPropertyAssignment,
722
682
  validate: (s) => s.getName() === "content",
723
- skip: j.JSDoc
683
+ skip: F.JSDoc
724
684
  }), i = t == null ? void 0 : t.getInitializer();
725
- return d.isArrayLiteralExpression(i) ? i : null;
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 Se extends U {
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
- r.info("Updating npm scripts...");
722
+ o.info("Updating npm scripts...");
758
723
  const t = c.read("package.json");
759
724
  if (!t)
760
- return r.fail("Could not find package.json file");
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
- r.info("Updating .gitignore");
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 U {
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 V = [new $e(), new Se()].reduce(
799
- (o, e) => Object.assign(o, { [e.name]: e }),
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 A extends g {
767
+ class D extends g {
803
768
  constructor(t) {
804
769
  super();
805
- a(this, "plugin");
806
- this.plugin = V[t] ?? r.fail(`Plugin '${t}' doesn't exist. Available plugins: ${Object.keys(V).join(", ")}`);
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
- a(A, "command", "install"), a(A, "description", "Install an AerogelJS plugin"), a(A, "parameters", [["plugin", "Plugin to install"]]);
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()), $.define(t), b.define(t), F.define(t), D.define(t), C.define(t), B.define(t), A.define(t), t.parse(e);
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 = x(new S(
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 (!N(t))
789
+ if (!O(t))
825
790
  throw new Error(e);
826
- return JSON.parse(z(t).toString()).version ?? ce(e);
791
+ return JSON.parse(z(t).toString()).version ?? oe(e);
827
792
  }
828
793
  }
829
- const Te = L(be);
794
+ const Te = C(be);
830
795
  export {
831
796
  Te as CLI
832
797
  };