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