@aerogel/cli 0.0.0-next.47ed8ee3c048720794026e45140e9b700cb428b9 → 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/bin/gel +4 -0
- package/dist/aerogel-cli.d.ts +2 -2
- package/dist/aerogel-cli.js +833 -0
- package/dist/aerogel-cli.js.map +1 -0
- package/package.json +27 -33
- package/src/cli.ts +30 -6
- package/src/commands/Command.ts +14 -9
- package/src/commands/create.test.ts +24 -7
- package/src/commands/create.ts +38 -20
- package/src/commands/generate-component.test.ts +62 -4
- package/src/commands/generate-component.ts +181 -28
- package/src/commands/generate-model.test.ts +8 -5
- package/src/commands/generate-model.ts +41 -24
- package/src/commands/generate-overrides.ts +85 -0
- package/src/commands/generate-service.test.ts +21 -0
- package/src/commands/generate-service.ts +151 -0
- package/src/commands/info.ts +15 -0
- package/src/commands/install.test.ts +27 -0
- package/src/commands/install.ts +32 -0
- package/src/lib/App.ts +71 -6
- package/src/lib/Editor.ts +57 -0
- package/src/lib/File.mock.ts +7 -11
- package/src/lib/File.ts +9 -3
- package/src/lib/Log.mock.ts +11 -6
- package/src/lib/Log.test.ts +22 -6
- package/src/lib/Log.ts +43 -27
- package/src/lib/Shell.mock.ts +3 -3
- package/src/lib/Shell.ts +2 -2
- package/src/lib/Template.ts +24 -17
- package/src/lib/utils/app.ts +15 -0
- package/src/lib/utils/edit.ts +44 -0
- package/src/lib/utils/paths.ts +42 -0
- package/src/plugins/Plugin.ts +159 -0
- package/src/plugins/Solid.ts +71 -0
- package/src/plugins/Soukai.ts +19 -0
- package/src/testing/setup.ts +56 -25
- package/templates/app/.github/workflows/ci.yml +16 -4
- package/templates/app/.nvmrc +1 -1
- package/templates/app/.vscode/launch.json +17 -0
- package/templates/app/.vscode/settings.json +10 -0
- package/templates/app/README.md +3 -0
- package/templates/app/cypress/cypress.config.ts +14 -0
- package/templates/app/cypress/support/e2e.ts +1 -3
- package/templates/app/cypress/tsconfig.json +7 -8
- package/templates/app/index.html +5 -4
- package/templates/app/package.json +44 -21
- package/templates/app/src/App.vue +5 -3
- package/templates/app/src/assets/css/main.css +4 -0
- package/templates/app/src/assets/public/robots.txt +2 -0
- package/templates/app/src/main.ts +8 -4
- package/templates/app/src/types/globals.d.ts +0 -1
- package/templates/app/tsconfig.json +3 -9
- package/templates/app/vite.config.ts +18 -8
- package/templates/component-button/[component.name].vue +42 -0
- package/templates/component-button-story/[component.name].story.vue +77 -0
- package/templates/component-checkbox/[component.name].vue +34 -0
- package/templates/component-checkbox-story/[component.name].story.vue +63 -0
- package/templates/component-input/[component.name].vue +17 -0
- package/templates/component-input-story/[component.name].story.vue +63 -0
- package/templates/overrides/components/index.ts +15 -0
- package/templates/overrides/components/overrides/AlertModal.vue +11 -0
- package/templates/overrides/components/overrides/ConfirmModal.vue +20 -0
- package/templates/overrides/components/overrides/ErrorReportModal.vue +35 -0
- package/templates/overrides/components/overrides/LoadingModal.vue +12 -0
- package/templates/overrides/components/overrides/ModalWrapper.vue +22 -0
- package/templates/overrides/components/overrides/SnackbarNotification.vue +34 -0
- package/templates/overrides-story/Overrides.story.vue +86 -0
- package/templates/service/[service.name].ts +8 -0
- package/.eslintrc.js +0 -7
- package/bin/ag +0 -4
- package/dist/aerogel-cli.cjs.js +0 -2
- package/dist/aerogel-cli.cjs.js.map +0 -1
- package/dist/aerogel-cli.esm.js +0 -2
- package/dist/aerogel-cli.esm.js.map +0 -1
- package/noeldemartin.config.js +0 -4
- package/src/lib/utils.test.ts +0 -33
- package/src/lib/utils.ts +0 -44
- package/templates/app/cypress.config.ts +0 -8
- package/templates/app/postcss.config.js +0 -6
- package/templates/app/src/assets/styles.css +0 -3
- package/templates/app/tailwind.config.js +0 -5
- package/tsconfig.json +0 -11
- package/vite.config.ts +0 -14
- /package/src/{main.ts → index.ts} +0 -0
package/dist/aerogel-cli.esm.js
DELETED
|
@@ -1,2 +0,0 @@
|
|
|
1
|
-
import{Command as e}from"commander";import t from"@babel/runtime/helpers/esm/defineProperty";import{facade as s,arrayFrom as n,stringMatchAll as i,toString as r,stringToSlug as o,stringToStudlyCase as a}from"@noeldemartin/utils";import{existsSync as c,readFileSync as l,readdirSync as m,lstatSync as p,mkdirSync as d,writeFileSync as h}from"fs";import{resolve as u,dirname as f}from"path";import"core-js/modules/esnext.async-iterator.for-each.js";import"core-js/modules/esnext.iterator.constructor.js";import"core-js/modules/esnext.iterator.for-each.js";import{hex as g,bold as y}from"chalk";import{cursorTo as w,clearLine as v}from"readline";import"core-js/modules/esnext.async-iterator.reduce.js";import"core-js/modules/esnext.iterator.reduce.js";import{render as $}from"mustache";import{exec as x}from"child_process";import"core-js/modules/esnext.async-iterator.map.js";import"core-js/modules/esnext.iterator.map.js";var j=s(new class{contains(e,t){return!!this.read(e)?.includes(t)}exists(e){return c(e)}read(e){return this.isFile(e)?l(e).toString():null}getFiles(e){const t=m(e,{withFileTypes:!0}),s=[];for(const n of t){const t=u(e,n.name);n.isDirectory()?s.push(...this.getFiles(t)):s.push(t)}return s}isDirectory(e){return this.exists(e)&&p(e).isDirectory()}isFile(e){return this.exists(e)&&p(e).isFile()}isEmptyDirectory(e){return!!this.isDirectory(e)&&0===this.getFiles(e).length}makeDirectory(e){d(e,{recursive:!0})}write(e,t){c(f(e))||d(f(e),{recursive:!0}),h(e,t)}});var D=s(new class{constructor(){t(this,"renderInfo",g("#00ffff")),t(this,"renderSuccess",g("#00ff00")),t(this,"renderError",g("#ff0000"))}async animate(e,t){var s=this;const n=function(){let t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"";const n=s.renderInfo(s.renderMarkdown(e)+".".repeat(i%4))+t;s.stdout(n)};let i=0;n();const r=setInterval((()=>(i++,n())),1e3),o=await t();return clearInterval(r),n("\n"),o}info(e){n(e).forEach((e=>{this.log(this.renderInfo(this.renderMarkdown(e)))}))}error(e){n(e).forEach((e=>{this.log(this.renderError(this.renderMarkdown(e)))}))}fail(e){this.error(e),process.exit(1)}success(e){n(e).forEach((e=>{this.log(this.renderSuccess(this.renderMarkdown(e)))}))}renderMarkdown(e){const t=i(e,/\*\*(.*)\*\*/g);for(const s of t)e=e.replace(s[0],y(s[1]));return e}log(e){n(e).forEach((e=>console.log(e)))}stdout(e){w(process.stdout,0),v(process.stdout,0),process.stdout.write(e)}});class k{static instantiate(e,t,s){return new k(e).instantiate(t,s)}constructor(e){t(this,"path",void 0),this.path=e}instantiate(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};const s=this.getFilenameReplacements(t),n=[];e=`${e}/`.replace(/\/\//,"/");for(const i of j.getFiles(this.path)){const r=Object.entries(s).reduce(((e,t)=>{let[s,n]=t;return e.replaceAll(s,n)}),i.substring(this.path.length+1)),o=l(i).toString(),a=e+(r.endsWith(".template")?r.slice(0,-9):r);j.write(a,$(o,t,void 0,["<%","%>"])),n.push(a)}return n}getFilenameReplacements(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"";return Object.entries(e).reduce(((e,s)=>{let[n,i]=s;return"object"==typeof i?Object.assign(e,this.getFilenameReplacements(i,`${n}.`)):e[`[${t}${n}]`]=r(i),e}),{})}}function A(e){return u(__dirname,"../",e)}class F{constructor(e){t(this,"name",void 0),this.name=e}create(e){!j.exists(e)||j.isDirectory(e)&&j.isEmptyDirectory(e)||D.fail(`Folder at '${e}' already exists!`),k.instantiate(A("templates/app"),e,{app:{name:this.name,slug:o(this.name)}})}}class I{static define(e){var t=this;e=e.command(this.command).description(this.description);for(const[t,s]of this.parameters)e=e.argument(`<${t}>`,s);for(const[t,s]of Object.entries(this.options)){const n="string"==typeof s?s:s.description,i="string"==typeof s?"string":s.type??"string";e=e.option("boolean"===i?`--${t}`:`--${t} <${i}>`,n)}e=e.action((function(){for(var e=arguments.length,s=new Array(e),n=0;n<e;n++)s[n]=arguments[n];return t.run.call(t,...s)}))}static async run(){for(var e=arguments.length,t=new Array(e),s=0;s<e;s++)t[s]=arguments[s];const n=new this(...t);await n.run()}async run(){}assertAerogelOrDirectory(e){const t=j.read("package.json");if(t?.includes("@aerogel/core"))return;if(e&&j.isDirectory(e))return;const s=e?`${e} folder does not exist.`:"package.json does not contain @aerogel/core.";D.fail(`${s} Are you sure this is an Aerogel app?`)}}t(I,"command",""),t(I,"description",""),t(I,"parameters",[]),t(I,"options",{});var S=s(new class{constructor(){t(this,"cwd",null)}setWorkingDirectory(e){this.cwd=e}async run(e){await new Promise(((t,s)=>{x(e,{cwd:this.cwd??void 0},(e=>{e?s(e):t()}))}))}});class b extends I{constructor(e,s){super(),t(this,"path",void 0),t(this,"options",void 0),this.path=e,this.options=s}async run(){const e=this.path,t=this.options.name??"Aerogel App";S.setWorkingDirectory(e),await this.createApp(t,e),await this.installDependencies(),await this.initializeGit(),D.success(["",`That's it! You can start working on **${t}** doing the following:`,` cd ${e}`," npm run dev","","Have fun!"])}async createApp(e,t){D.info(`Creating **${e}**...`),new F(e).create(t)}async installDependencies(){await D.animate("Installing dependencies",(async()=>{await S.run("npm install")}))}async initializeGit(){await D.animate("Initializing git",(async()=>{await S.run("git init"),await S.run("git add ."),await S.run('git commit -m "Start"')}))}}t(b,"command","create"),t(b,"description","Create AerogelJS app"),t(b,"parameters",[["path","Application path"]]),t(b,"options",{name:"Application name"});class E extends I{constructor(e){let s=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};super(),t(this,"name",void 0),t(this,"options",void 0),this.name=e,this.options=s}async run(){this.assertAerogelOrDirectory("src/components"),this.options.story&&this.assertHistoireInstalled(),j.exists(`src/components/${this.name}.vue`)&&D.fail(`${this.name} component already exists!`);const e=k.instantiate(A("templates/component"),"src/components",{component:{name:this.name}});if(this.options.story){const t=k.instantiate(A("templates/component-story"),"src/components",{component:{name:this.name}});e.push(...t)}const t=e.map((e=>`- ${e}`)).join("\n");D.info(`${this.name} component created successfully! The following files were created:\n\n${t}`)}assertHistoireInstalled(){j.exists("src/main.histoire.ts")||D.fail("Histoire is not installed yet!")}}t(E,"command","generate:component"),t(E,"description","Generate an AerogelJS component"),t(E,"parameters",[["name","Component name"]]),t(E,"options",{story:{description:"Create component story using Histoire",type:"boolean"}});class O extends I{constructor(e){let s=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};super(),t(this,"name",void 0),t(this,"options",void 0),this.name=e,this.options=s}async run(){this.assertAerogelOrDirectory("src/models"),j.exists(`src/models/${this.name}.ts`)&&D.fail(`${this.name} model already exists!`),this.assertSoukaiInstalled();const e=k.instantiate(A("templates/model"),"src/models",{model:{name:this.name,fieldsDefinition:this.getFieldsDefinition()},soukaiImports:this.options.fields?"FieldType, defineModelSchema":"defineModelSchema"}).map((e=>`- ${e}`)).join("\n");D.info(`${this.name} model created successfully! The following files were created:\n\n${e}`)}getFieldsDefinition(){if(!this.options.fields)return" //";return function(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};const s=e.split("\n"),n=t.indent??0;let i=0,r="";for(const e of s){const t=e.trim(),s=0===t.length;if(0===r.length){if(s)continue;i=e.indexOf(t[0]??""),r+=`${" ".repeat(n)}${t}\n`;continue}if(s){r+="\n";continue}const o=e.indexOf(t[0]??"");r+=`${" ".repeat(n+o-i)}${t}\n`}return r.trimEnd()}(this.options.fields.split(",").map((e=>{const[t,s]=e.split(":");return{name:t,type:a(s??"string")}})).reduce(((e,t)=>e+`\n${t.name}: FieldType.${t.type},`),""),{indent:8})}assertSoukaiInstalled(){j.contains("package.json",'"soukai"')||D.fail("Soukai is not installed yet!")}}t(O,"command","generate:model"),t(O,"description","Generate an AerogelJS model"),t(O,"parameters",[["name","Model name"]]),t(O,"options",{fields:"Create model with the given fields"});var C=s(new class{run(t){const s=new e;s.name("ag").description("AerogelJS CLI").version("0.0.0"),b.define(s),E.define(s),O.define(s),s.parse(t)}});export{C as CLI};
|
|
2
|
-
//# sourceMappingURL=aerogel-cli.esm.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"aerogel-cli.esm.js","sources":[],"sourcesContent":[],"names":[],"mappings":""}
|
package/noeldemartin.config.js
DELETED
package/src/lib/utils.test.ts
DELETED
|
@@ -1,33 +0,0 @@
|
|
|
1
|
-
import { describe, expect, it } from 'vitest';
|
|
2
|
-
|
|
3
|
-
import { formatCodeBlock } from './utils';
|
|
4
|
-
|
|
5
|
-
describe('Utils', () => {
|
|
6
|
-
|
|
7
|
-
it('Formats code blocks', () => {
|
|
8
|
-
// Arrange
|
|
9
|
-
const raw = `
|
|
10
|
-
|
|
11
|
-
const foo = 'bar';
|
|
12
|
-
|
|
13
|
-
if (foo) {
|
|
14
|
-
doSomething();
|
|
15
|
-
}
|
|
16
|
-
|
|
17
|
-
`;
|
|
18
|
-
const formatted = [
|
|
19
|
-
'const foo = \'bar\';', //
|
|
20
|
-
'', //
|
|
21
|
-
'if (foo) {', //
|
|
22
|
-
' doSomething();', //
|
|
23
|
-
'}', //
|
|
24
|
-
].join('\n');
|
|
25
|
-
|
|
26
|
-
// Act
|
|
27
|
-
const actual = formatCodeBlock(raw);
|
|
28
|
-
|
|
29
|
-
// Assert
|
|
30
|
-
expect(actual).toEqual(formatted);
|
|
31
|
-
});
|
|
32
|
-
|
|
33
|
-
});
|
package/src/lib/utils.ts
DELETED
|
@@ -1,44 +0,0 @@
|
|
|
1
|
-
import { resolve } from 'path';
|
|
2
|
-
|
|
3
|
-
export interface FormatCodeBlockOptions {
|
|
4
|
-
indent?: number;
|
|
5
|
-
}
|
|
6
|
-
|
|
7
|
-
export function basePath(path: string): string {
|
|
8
|
-
return resolve(__dirname, '../', path);
|
|
9
|
-
}
|
|
10
|
-
|
|
11
|
-
export function formatCodeBlock(code: string, options: FormatCodeBlockOptions = {}): string {
|
|
12
|
-
const lines = code.split('\n');
|
|
13
|
-
const indent = options.indent ?? 0;
|
|
14
|
-
let originalIndent = 0;
|
|
15
|
-
let formatted = '';
|
|
16
|
-
|
|
17
|
-
for (const line of lines) {
|
|
18
|
-
const trimmedLine = line.trim();
|
|
19
|
-
const isEmptyLine = trimmedLine.length === 0;
|
|
20
|
-
|
|
21
|
-
if (formatted.length === 0) {
|
|
22
|
-
if (isEmptyLine) {
|
|
23
|
-
continue;
|
|
24
|
-
}
|
|
25
|
-
|
|
26
|
-
originalIndent = line.indexOf(trimmedLine[0] ?? '');
|
|
27
|
-
formatted += `${' '.repeat(indent)}${trimmedLine}\n`;
|
|
28
|
-
|
|
29
|
-
continue;
|
|
30
|
-
}
|
|
31
|
-
|
|
32
|
-
if (isEmptyLine) {
|
|
33
|
-
formatted += '\n';
|
|
34
|
-
|
|
35
|
-
continue;
|
|
36
|
-
}
|
|
37
|
-
|
|
38
|
-
const lineIndent = line.indexOf(trimmedLine[0] ?? '');
|
|
39
|
-
|
|
40
|
-
formatted += `${' '.repeat(indent + lineIndent - originalIndent)}${trimmedLine}\n`;
|
|
41
|
-
}
|
|
42
|
-
|
|
43
|
-
return formatted.trimEnd();
|
|
44
|
-
}
|
package/tsconfig.json
DELETED
package/vite.config.ts
DELETED
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
import { defineConfig } from 'vitest/config';
|
|
2
|
-
import { resolve } from 'path';
|
|
3
|
-
|
|
4
|
-
export default defineConfig({
|
|
5
|
-
test: {
|
|
6
|
-
clearMocks: true,
|
|
7
|
-
setupFiles: ['./src/testing/setup.ts'],
|
|
8
|
-
},
|
|
9
|
-
resolve: {
|
|
10
|
-
alias: {
|
|
11
|
-
'@': resolve(__dirname, './src'),
|
|
12
|
-
},
|
|
13
|
-
},
|
|
14
|
-
});
|
|
File without changes
|