@aerogel/cli 0.0.0-next.d4e50d20bf4c270c2068f0a4398e9304ee4a062e → 0.0.0-next.d803ba42263b449637ede53bb8ce9a147e781512
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 +1 -1
- package/dist/aerogel-cli.d.ts +1 -2
- package/dist/aerogel-cli.js +781 -0
- package/dist/aerogel-cli.js.map +1 -0
- package/package.json +21 -33
- package/src/cli.ts +10 -12
- package/src/commands/Command.ts +3 -3
- package/src/commands/create.test.ts +2 -25
- package/src/commands/create.ts +15 -19
- package/src/commands/generate-component.test.ts +1 -61
- package/src/commands/generate-component.ts +14 -79
- package/src/commands/generate-model.test.ts +1 -1
- package/src/commands/generate-model.ts +11 -11
- package/src/commands/generate-service.test.ts +2 -2
- package/src/commands/generate-service.ts +14 -14
- package/src/commands/info.ts +7 -6
- package/src/commands/install.test.ts +63 -14
- package/src/commands/install.ts +29 -15
- package/src/lib/App.ts +47 -49
- package/src/lib/Editor.ts +3 -4
- package/src/lib/File.mock.ts +7 -11
- package/src/lib/File.ts +14 -3
- package/src/lib/Log.mock.ts +4 -8
- package/src/lib/Log.test.ts +4 -4
- package/src/lib/Log.ts +7 -7
- package/src/lib/Shell.mock.ts +6 -2
- package/src/lib/Shell.ts +2 -2
- package/src/lib/Template.ts +19 -16
- package/src/lib/utils/app.ts +2 -2
- package/src/lib/utils/edit.ts +2 -2
- package/src/lib/utils/paths.ts +19 -7
- package/src/plugins/LocalFirst.ts +9 -0
- package/src/plugins/Plugin.ts +37 -39
- package/src/plugins/Solid.ts +18 -24
- package/src/plugins/Soukai.ts +8 -7
- package/src/testing/setup.ts +36 -31
- package/src/utils/package.ts +23 -0
- package/templates/service/[service.name].ts +1 -1
- package/.prettierignore +0 -1
- 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/src/commands/generate-overrides.ts +0 -85
- package/src/plugins/Histoire.ts +0 -105
- 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 -16
- 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 -12
- package/templates/app/index.html +0 -13
- package/templates/app/package.json +0 -66
- package/templates/app/postcss.config.js +0 -6
- package/templates/app/src/App.vue +0 -12
- package/templates/app/src/assets/css/styles.css +0 -3
- 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/tailwind.config.js +0 -5
- package/templates/app/tsconfig.json +0 -19
- package/templates/app/vite.config.ts +0 -29
- package/templates/component-button/[component.name].vue +0 -42
- package/templates/component-button-story/[component.name].story.vue +0 -77
- package/templates/component-input/[component.name].vue +0 -16
- package/templates/component-input-story/[component.name].story.vue +0 -63
- package/templates/component-story/[component.name].story.vue +0 -7
- package/templates/histoire/histoire.config.ts +0 -7
- package/templates/histoire/patches/histoire+0.17.6.patch +0 -13
- package/templates/histoire/src/main.histoire.ts +0 -8
- package/templates/overrides/components/index.ts +0 -15
- package/templates/overrides/components/overrides/AlertModal.vue +0 -11
- package/templates/overrides/components/overrides/ConfirmModal.vue +0 -20
- package/templates/overrides/components/overrides/ErrorReportModal.vue +0 -35
- package/templates/overrides/components/overrides/LoadingModal.vue +0 -12
- package/templates/overrides/components/overrides/ModalWrapper.vue +0 -22
- package/templates/overrides/components/overrides/SnackbarNotification.vue +0 -34
- package/templates/overrides-story/Overrides.story.vue +0 -86
- package/templates/postcss-pseudo-classes/postcss.config.js +0 -15
- package/tsconfig.json +0 -11
- package/vite.config.ts +0 -14
- /package/src/{main.ts → index.ts} +0 -0
|
@@ -2,69 +2,44 @@ import { arrayFrom, stringToSlug } from '@noeldemartin/utils';
|
|
|
2
2
|
import { Node, SyntaxKind } from 'ts-morph';
|
|
3
3
|
import type { ArrayLiteralExpression, CallExpression, SourceFile } from 'ts-morph';
|
|
4
4
|
|
|
5
|
-
import Command from '
|
|
6
|
-
import File from '
|
|
7
|
-
import Log from '
|
|
8
|
-
import Template from '
|
|
9
|
-
import { app } from '
|
|
10
|
-
import { editFiles, findDescendant } from '
|
|
11
|
-
import { templatePath } from '
|
|
12
|
-
import type { CommandOptions } from '@/commands/Command';
|
|
5
|
+
import Command from '@aerogel/cli/commands/Command';
|
|
6
|
+
import File from '@aerogel/cli/lib/File';
|
|
7
|
+
import Log from '@aerogel/cli/lib/Log';
|
|
8
|
+
import Template from '@aerogel/cli/lib/Template';
|
|
9
|
+
import { app } from '@aerogel/cli/lib/utils/app';
|
|
10
|
+
import { editFiles, findDescendant } from '@aerogel/cli/lib/utils/edit';
|
|
11
|
+
import { templatePath } from '@aerogel/cli/lib/utils/paths';
|
|
13
12
|
|
|
14
13
|
export interface Options {
|
|
15
14
|
button?: boolean;
|
|
15
|
+
checkbox?: boolean;
|
|
16
16
|
input?: boolean;
|
|
17
17
|
story?: boolean;
|
|
18
18
|
}
|
|
19
19
|
|
|
20
20
|
export class GenerateComponentCommand extends Command {
|
|
21
21
|
|
|
22
|
-
protected static command: string = 'generate:component';
|
|
23
|
-
protected static description: string = 'Generate an AerogelJS Component';
|
|
24
|
-
protected static parameters: [string, string][] = [
|
|
22
|
+
protected static override command: string = 'generate:component';
|
|
23
|
+
protected static override description: string = 'Generate an AerogelJS Component';
|
|
24
|
+
protected static override parameters: [string, string][] = [
|
|
25
25
|
['path', 'Component path (relative to components folder; extension not necessary)'],
|
|
26
26
|
];
|
|
27
27
|
|
|
28
|
-
protected static options: CommandOptions = {
|
|
29
|
-
button: {
|
|
30
|
-
description: 'Create a custom button',
|
|
31
|
-
type: 'boolean',
|
|
32
|
-
},
|
|
33
|
-
input: {
|
|
34
|
-
description: 'Create a custom input',
|
|
35
|
-
type: 'boolean',
|
|
36
|
-
},
|
|
37
|
-
story: {
|
|
38
|
-
description: 'Create component story using Histoire',
|
|
39
|
-
type: 'boolean',
|
|
40
|
-
},
|
|
41
|
-
};
|
|
42
|
-
|
|
43
28
|
private path: string;
|
|
44
|
-
private options: Options;
|
|
45
29
|
|
|
46
|
-
constructor(path: string
|
|
30
|
+
constructor(path: string) {
|
|
47
31
|
super();
|
|
48
32
|
|
|
49
33
|
this.path = path;
|
|
50
|
-
this.options = options;
|
|
51
|
-
}
|
|
52
|
-
|
|
53
|
-
protected async validate(): Promise<void> {
|
|
54
|
-
if (this.options.button && this.options.input) {
|
|
55
|
-
Log.fail('Cannot use both \'button\' and \'input\' flags!');
|
|
56
|
-
}
|
|
57
34
|
}
|
|
58
35
|
|
|
59
|
-
protected async run(): Promise<void> {
|
|
36
|
+
protected override async run(): Promise<void> {
|
|
60
37
|
this.assertAerogelOrDirectory('src/components');
|
|
61
|
-
this.assertHistoireInstalled();
|
|
62
38
|
|
|
63
39
|
const files = new Set<string>();
|
|
64
40
|
const [directoryName, componentName] = this.parsePathComponents();
|
|
65
41
|
|
|
66
42
|
await this.createComponent(directoryName, componentName, files);
|
|
67
|
-
await this.createStory(directoryName, componentName, files);
|
|
68
43
|
await this.declareComponents();
|
|
69
44
|
|
|
70
45
|
const filesList = arrayFrom(files)
|
|
@@ -74,31 +49,13 @@ export class GenerateComponentCommand extends Command {
|
|
|
74
49
|
Log.info(`${componentName} component created successfully! The following files were created:\n\n${filesList}`);
|
|
75
50
|
}
|
|
76
51
|
|
|
77
|
-
protected assertHistoireInstalled(): void {
|
|
78
|
-
if (!this.options.story) {
|
|
79
|
-
return;
|
|
80
|
-
}
|
|
81
|
-
|
|
82
|
-
if (!File.contains('package.json', '"histoire"') && !File.contains('package.json', '"@aerogel/histoire"')) {
|
|
83
|
-
Log.fail(`
|
|
84
|
-
Histoire is not installed yet! You can install it running:
|
|
85
|
-
npx gel install histoire
|
|
86
|
-
`);
|
|
87
|
-
}
|
|
88
|
-
}
|
|
89
|
-
|
|
90
52
|
protected async createComponent(directoryName: string, componentName: string, files: Set<string>): Promise<void> {
|
|
91
53
|
await Log.animate('Creating component', async () => {
|
|
92
54
|
if (File.exists(`src/components/${this.path}.vue`)) {
|
|
93
55
|
Log.fail(`${this.path} component already exists!`);
|
|
94
56
|
}
|
|
95
57
|
|
|
96
|
-
const
|
|
97
|
-
? 'component-input'
|
|
98
|
-
: this.options.button
|
|
99
|
-
? 'component-button'
|
|
100
|
-
: 'component';
|
|
101
|
-
const componentFiles = Template.instantiate(templatePath(templateName), `src/components/${directoryName}`, {
|
|
58
|
+
const componentFiles = Template.instantiate(templatePath('component'), `src/components/${directoryName}`, {
|
|
102
59
|
component: {
|
|
103
60
|
name: componentName,
|
|
104
61
|
slug: stringToSlug(componentName),
|
|
@@ -109,28 +66,6 @@ export class GenerateComponentCommand extends Command {
|
|
|
109
66
|
});
|
|
110
67
|
}
|
|
111
68
|
|
|
112
|
-
protected async createStory(directoryName: string, componentName: string, files: Set<string>): Promise<void> {
|
|
113
|
-
if (!this.options.story) {
|
|
114
|
-
return;
|
|
115
|
-
}
|
|
116
|
-
|
|
117
|
-
await Log.animate('Creating story', async () => {
|
|
118
|
-
const templateName = this.options.input
|
|
119
|
-
? 'component-input-story'
|
|
120
|
-
: this.options.button
|
|
121
|
-
? 'component-button-story'
|
|
122
|
-
: 'component-story';
|
|
123
|
-
const storyFiles = Template.instantiate(templatePath(templateName), `src/components/${directoryName}`, {
|
|
124
|
-
component: {
|
|
125
|
-
name: componentName,
|
|
126
|
-
slug: stringToSlug(componentName),
|
|
127
|
-
},
|
|
128
|
-
});
|
|
129
|
-
|
|
130
|
-
storyFiles.forEach((file) => files.add(file));
|
|
131
|
-
});
|
|
132
|
-
}
|
|
133
|
-
|
|
134
69
|
protected async declareComponents(): Promise<void> {
|
|
135
70
|
if (!editFiles()) {
|
|
136
71
|
return;
|
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
import { formatCodeBlock, stringToStudlyCase } from '@noeldemartin/utils';
|
|
2
2
|
|
|
3
|
-
import Command from '
|
|
4
|
-
import File from '
|
|
5
|
-
import Log from '
|
|
6
|
-
import Template from '
|
|
7
|
-
import { templatePath } from '
|
|
8
|
-
import type { CommandOptions } from '
|
|
3
|
+
import Command from '@aerogel/cli/commands/Command';
|
|
4
|
+
import File from '@aerogel/cli/lib/File';
|
|
5
|
+
import Log from '@aerogel/cli/lib/Log';
|
|
6
|
+
import Template from '@aerogel/cli/lib/Template';
|
|
7
|
+
import { templatePath } from '@aerogel/cli/lib/utils/paths';
|
|
8
|
+
import type { CommandOptions } from '@aerogel/cli/commands/Command';
|
|
9
9
|
|
|
10
10
|
interface Options {
|
|
11
11
|
fields?: string;
|
|
@@ -13,10 +13,10 @@ interface Options {
|
|
|
13
13
|
|
|
14
14
|
export class GenerateModelCommand extends Command {
|
|
15
15
|
|
|
16
|
-
protected static command: string = 'generate:model';
|
|
17
|
-
protected static description: string = 'Generate an AerogelJS Model';
|
|
18
|
-
protected static parameters: [string, string][] = [['name', 'Model name']];
|
|
19
|
-
protected static options: CommandOptions = {
|
|
16
|
+
protected static override command: string = 'generate:model';
|
|
17
|
+
protected static override description: string = 'Generate an AerogelJS Model';
|
|
18
|
+
protected static override parameters: [string, string][] = [['name', 'Model name']];
|
|
19
|
+
protected static override options: CommandOptions = {
|
|
20
20
|
fields: 'Create model with the given fields',
|
|
21
21
|
};
|
|
22
22
|
|
|
@@ -30,7 +30,7 @@ export class GenerateModelCommand extends Command {
|
|
|
30
30
|
this.options = options;
|
|
31
31
|
}
|
|
32
32
|
|
|
33
|
-
protected async run(): Promise<void> {
|
|
33
|
+
protected override async run(): Promise<void> {
|
|
34
34
|
this.assertAerogelOrDirectory('src/models');
|
|
35
35
|
|
|
36
36
|
if (File.exists(`src/models/${this.name}.ts`)) {
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { describe, it } from 'vitest';
|
|
2
2
|
|
|
3
|
-
import FileMock from '
|
|
3
|
+
import FileMock from '@aerogel/cli/lib/File.mock';
|
|
4
4
|
|
|
5
5
|
import { GenerateServiceCommand } from './generate-service';
|
|
6
6
|
|
|
@@ -15,7 +15,7 @@ describe('Generate Service command', () => {
|
|
|
15
15
|
|
|
16
16
|
// Assert
|
|
17
17
|
FileMock.expectCreated('src/services/FooBar.ts').toContain('class FooBarService extends Service');
|
|
18
|
-
FileMock.expectCreated('src/services/FooBar.ts').toContain('export default facade(
|
|
18
|
+
FileMock.expectCreated('src/services/FooBar.ts').toContain('export default facade(FooBarService);');
|
|
19
19
|
});
|
|
20
20
|
|
|
21
21
|
});
|
|
@@ -2,20 +2,20 @@ import { arrayFrom, formatCodeBlock, stringToCamelCase } from '@noeldemartin/uti
|
|
|
2
2
|
import { Node, SyntaxKind } from 'ts-morph';
|
|
3
3
|
import type { ObjectLiteralExpression, SourceFile } from 'ts-morph';
|
|
4
4
|
|
|
5
|
-
import Command from '
|
|
6
|
-
import File from '
|
|
7
|
-
import Log from '
|
|
8
|
-
import Template from '
|
|
9
|
-
import { app } from '
|
|
10
|
-
import { templatePath } from '
|
|
11
|
-
import { editFiles, findDescendant } from '
|
|
12
|
-
import type { Editor } from '
|
|
5
|
+
import Command from '@aerogel/cli/commands/Command';
|
|
6
|
+
import File from '@aerogel/cli/lib/File';
|
|
7
|
+
import Log from '@aerogel/cli/lib/Log';
|
|
8
|
+
import Template from '@aerogel/cli/lib/Template';
|
|
9
|
+
import { app } from '@aerogel/cli/lib/utils/app';
|
|
10
|
+
import { templatePath } from '@aerogel/cli/lib/utils/paths';
|
|
11
|
+
import { editFiles, findDescendant } from '@aerogel/cli/lib/utils/edit';
|
|
12
|
+
import type { Editor } from '@aerogel/cli/lib/Editor';
|
|
13
13
|
|
|
14
14
|
export class GenerateServiceCommand extends Command {
|
|
15
15
|
|
|
16
|
-
protected static command: string = 'generate:service';
|
|
17
|
-
protected static description: string = 'Generate an AerogelJS Service';
|
|
18
|
-
protected static parameters: [string, string][] = [['name', 'Service name']];
|
|
16
|
+
protected static override command: string = 'generate:service';
|
|
17
|
+
protected static override description: string = 'Generate an AerogelJS Service';
|
|
18
|
+
protected static override parameters: [string, string][] = [['name', 'Service name']];
|
|
19
19
|
|
|
20
20
|
private name: string;
|
|
21
21
|
|
|
@@ -25,7 +25,7 @@ export class GenerateServiceCommand extends Command {
|
|
|
25
25
|
this.name = name;
|
|
26
26
|
}
|
|
27
27
|
|
|
28
|
-
protected async run(): Promise<void> {
|
|
28
|
+
protected override async run(): Promise<void> {
|
|
29
29
|
this.assertAerogelOrDirectory('src/services');
|
|
30
30
|
|
|
31
31
|
const files = new Set<string>();
|
|
@@ -95,8 +95,8 @@ export class GenerateServiceCommand extends Command {
|
|
|
95
95
|
|
|
96
96
|
export type AppServices = typeof services;
|
|
97
97
|
|
|
98
|
-
declare module '@
|
|
99
|
-
interface
|
|
98
|
+
declare module '@aerogel/core' {
|
|
99
|
+
interface Services extends AppServices {}
|
|
100
100
|
}
|
|
101
101
|
`),
|
|
102
102
|
);
|
package/src/commands/info.ts
CHANGED
|
@@ -1,14 +1,15 @@
|
|
|
1
|
-
import
|
|
2
|
-
import Log from '@/lib/Log';
|
|
1
|
+
import { URL, fileURLToPath } from 'node:url';
|
|
3
2
|
|
|
3
|
+
import Command from '@aerogel/cli/commands/Command';
|
|
4
|
+
import Log from '@aerogel/cli/lib/Log';
|
|
4
5
|
export class InfoCommand extends Command {
|
|
5
6
|
|
|
6
|
-
protected static command: string = 'info';
|
|
7
|
-
protected static description: string = 'Show debugging information about the CLI';
|
|
7
|
+
protected static override command: string = 'info';
|
|
8
|
+
protected static override description: string = 'Show debugging information about the CLI';
|
|
8
9
|
|
|
9
|
-
protected async run(): Promise<void> {
|
|
10
|
+
protected override async run(): Promise<void> {
|
|
10
11
|
Log.info('[AerogelJS CLI info]');
|
|
11
|
-
Log.info('Installation directory: ' +
|
|
12
|
+
Log.info('Installation directory: ' + fileURLToPath(new URL(/* @vite-ignore */ './', import.meta.url)));
|
|
12
13
|
}
|
|
13
14
|
|
|
14
15
|
}
|
|
@@ -1,41 +1,90 @@
|
|
|
1
|
-
import { describe, it } from 'vitest';
|
|
1
|
+
import { describe, expect, it } from 'vitest';
|
|
2
2
|
|
|
3
|
-
import
|
|
4
|
-
import
|
|
3
|
+
import ShellMock from '@aerogel/cli/lib/Shell.mock';
|
|
4
|
+
import FileMock from '@aerogel/cli/lib/File.mock';
|
|
5
5
|
|
|
6
6
|
import { InstallCommand } from './install';
|
|
7
7
|
|
|
8
8
|
describe('Install plugin command', () => {
|
|
9
9
|
|
|
10
10
|
it('installs solid', async () => {
|
|
11
|
+
// Arrange
|
|
12
|
+
stubPackageJson();
|
|
13
|
+
|
|
11
14
|
// Act
|
|
12
15
|
await InstallCommand.run('solid');
|
|
13
16
|
|
|
14
17
|
// Assert
|
|
15
|
-
ShellMock.expectRan('
|
|
16
|
-
|
|
18
|
+
ShellMock.expectRan('pnpm install --no-save');
|
|
19
|
+
|
|
20
|
+
expectPackageJson({
|
|
21
|
+
dependencies: {
|
|
22
|
+
'@aerogel/core': 'next',
|
|
23
|
+
'@aerogel/plugin-solid': 'next',
|
|
24
|
+
'@noeldemartin/solid-utils': 'next',
|
|
25
|
+
'soukai-solid': 'next',
|
|
26
|
+
'vue': '^3.5.13',
|
|
27
|
+
},
|
|
28
|
+
});
|
|
17
29
|
});
|
|
18
30
|
|
|
19
31
|
it('installs soukai', async () => {
|
|
32
|
+
// Arrange
|
|
33
|
+
stubPackageJson();
|
|
34
|
+
|
|
20
35
|
// Act
|
|
21
|
-
await InstallCommand.run('soukai');
|
|
36
|
+
await InstallCommand.run('soukai', { skipInstall: true });
|
|
22
37
|
|
|
23
38
|
// Assert
|
|
24
|
-
ShellMock.
|
|
25
|
-
|
|
39
|
+
ShellMock.expectNotRan('pnpm install --no-save');
|
|
40
|
+
|
|
41
|
+
expectPackageJson({
|
|
42
|
+
dependencies: {
|
|
43
|
+
'@aerogel/core': 'next',
|
|
44
|
+
'@aerogel/plugin-soukai': 'next',
|
|
45
|
+
'soukai': 'next',
|
|
46
|
+
'vue': '^3.5.13',
|
|
47
|
+
},
|
|
48
|
+
});
|
|
26
49
|
});
|
|
27
50
|
|
|
28
|
-
it('installs
|
|
51
|
+
it('installs local-first', async () => {
|
|
29
52
|
// Arrange
|
|
30
|
-
|
|
53
|
+
stubPackageJson();
|
|
31
54
|
|
|
32
55
|
// Act
|
|
33
|
-
await InstallCommand.run('
|
|
56
|
+
await InstallCommand.run('local-first');
|
|
34
57
|
|
|
35
58
|
// Assert
|
|
36
|
-
ShellMock.expectRan('
|
|
37
|
-
|
|
38
|
-
|
|
59
|
+
ShellMock.expectRan('pnpm install --no-save');
|
|
60
|
+
|
|
61
|
+
expectPackageJson({
|
|
62
|
+
dependencies: {
|
|
63
|
+
'@aerogel/core': 'next',
|
|
64
|
+
'@aerogel/plugin-local-first': 'next',
|
|
65
|
+
'vue': '^3.5.13',
|
|
66
|
+
},
|
|
67
|
+
});
|
|
39
68
|
});
|
|
40
69
|
|
|
41
70
|
});
|
|
71
|
+
|
|
72
|
+
function stubPackageJson(): void {
|
|
73
|
+
FileMock.stub(
|
|
74
|
+
'package.json',
|
|
75
|
+
JSON.stringify(
|
|
76
|
+
{
|
|
77
|
+
dependencies: {
|
|
78
|
+
'@aerogel/core': 'next',
|
|
79
|
+
'vue': '^3.5.13',
|
|
80
|
+
},
|
|
81
|
+
},
|
|
82
|
+
null,
|
|
83
|
+
2,
|
|
84
|
+
),
|
|
85
|
+
);
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
function expectPackageJson(packageJson: object): void {
|
|
89
|
+
expect(JSON.parse(FileMock.read('package.json') ?? '{}')).toEqual(packageJson);
|
|
90
|
+
}
|
package/src/commands/install.ts
CHANGED
|
@@ -1,33 +1,47 @@
|
|
|
1
|
-
import Command from '
|
|
2
|
-
import
|
|
3
|
-
import
|
|
4
|
-
import
|
|
5
|
-
import
|
|
6
|
-
import type Plugin from '
|
|
7
|
-
|
|
8
|
-
|
|
1
|
+
import Command from '@aerogel/cli/commands/Command';
|
|
2
|
+
import LocalFirst from '@aerogel/cli/plugins/LocalFirst';
|
|
3
|
+
import Log from '@aerogel/cli/lib/Log';
|
|
4
|
+
import Solid from '@aerogel/cli/plugins/Solid';
|
|
5
|
+
import Soukai from '@aerogel/cli/plugins/Soukai';
|
|
6
|
+
import type Plugin from '@aerogel/cli/plugins/Plugin';
|
|
7
|
+
import type { CommandOptions } from '@aerogel/cli/commands/Command';
|
|
8
|
+
|
|
9
|
+
const plugins = [new Soukai(), new Solid(), new LocalFirst()].reduce(
|
|
9
10
|
(pluginsObject, plugin) => Object.assign(pluginsObject, { [plugin.name]: plugin }),
|
|
10
11
|
{} as Record<string, Plugin>,
|
|
11
12
|
);
|
|
13
|
+
export interface Options {
|
|
14
|
+
skipInstall?: boolean;
|
|
15
|
+
}
|
|
12
16
|
|
|
13
17
|
export class InstallCommand extends Command {
|
|
14
18
|
|
|
15
|
-
protected static command: string = 'install';
|
|
16
|
-
protected static description: string = 'Install an AerogelJS plugin';
|
|
17
|
-
protected static parameters: [string, string][] = [['plugin', 'Plugin to install']];
|
|
18
|
-
|
|
19
|
+
protected static override command: string = 'install';
|
|
20
|
+
protected static override description: string = 'Install an AerogelJS plugin';
|
|
21
|
+
protected static override parameters: [string, string][] = [['plugin', 'Plugin to install']];
|
|
22
|
+
protected static override options: CommandOptions = {
|
|
23
|
+
skipInstall: {
|
|
24
|
+
type: 'boolean',
|
|
25
|
+
description: 'Skip installing dependencies, just add them to package.json',
|
|
26
|
+
},
|
|
27
|
+
};
|
|
28
|
+
|
|
29
|
+
private options: Options;
|
|
19
30
|
private plugin: Plugin;
|
|
20
31
|
|
|
21
|
-
constructor(plugin: string) {
|
|
32
|
+
constructor(plugin: string, options: Options = {}) {
|
|
22
33
|
super();
|
|
23
34
|
|
|
35
|
+
this.options = options;
|
|
24
36
|
this.plugin =
|
|
25
37
|
plugins[plugin] ??
|
|
26
38
|
Log.fail(`Plugin '${plugin}' doesn't exist. Available plugins: ${Object.keys(plugins).join(', ')}`);
|
|
27
39
|
}
|
|
28
40
|
|
|
29
|
-
protected async run(): Promise<void> {
|
|
30
|
-
await this.plugin.install(
|
|
41
|
+
protected override async run(): Promise<void> {
|
|
42
|
+
await this.plugin.install({
|
|
43
|
+
skipInstall: this.options.skipInstall,
|
|
44
|
+
});
|
|
31
45
|
}
|
|
32
46
|
|
|
33
47
|
}
|
package/src/lib/App.ts
CHANGED
|
@@ -1,19 +1,11 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
3
|
-
import File from '
|
|
4
|
-
import Log from '
|
|
5
|
-
import Template from '
|
|
6
|
-
import { packNotFound, packagePackPath, packagePath, templatePath } from '
|
|
7
|
-
import { Editor } from '
|
|
8
|
-
|
|
9
|
-
interface Dependencies {
|
|
10
|
-
aerogelCli: string;
|
|
11
|
-
aerogelCore: string;
|
|
12
|
-
aerogelCypress: string;
|
|
13
|
-
aerogelPluginI18n: string;
|
|
14
|
-
aerogelPluginSoukai: string;
|
|
15
|
-
aerogelVite: string;
|
|
16
|
-
}
|
|
1
|
+
import { resolve } from 'node:path';
|
|
2
|
+
|
|
3
|
+
import File from '@aerogel/cli/lib/File';
|
|
4
|
+
import Log from '@aerogel/cli/lib/Log';
|
|
5
|
+
import Template from '@aerogel/cli/lib/Template';
|
|
6
|
+
import { packNotFound, packagePackPath, packagePath, templatePath } from '@aerogel/cli/lib/utils/paths';
|
|
7
|
+
import { Editor } from '@aerogel/cli/lib/Editor';
|
|
8
|
+
import { simpleGit } from 'simple-git';
|
|
17
9
|
|
|
18
10
|
export interface Options {
|
|
19
11
|
local?: boolean;
|
|
@@ -22,30 +14,43 @@ export interface Options {
|
|
|
22
14
|
|
|
23
15
|
export default class App {
|
|
24
16
|
|
|
25
|
-
constructor(
|
|
17
|
+
constructor(
|
|
18
|
+
protected name: string,
|
|
19
|
+
protected options: Options = {},
|
|
20
|
+
) {}
|
|
26
21
|
|
|
27
|
-
public create(path: string): void {
|
|
22
|
+
public async create(path: string): Promise<void> {
|
|
28
23
|
if (File.exists(path) && (!File.isDirectory(path) || !File.isEmptyDirectory(path))) {
|
|
29
24
|
Log.fail(`Folder at '${path}' already exists!`);
|
|
30
25
|
}
|
|
31
26
|
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
27
|
+
// Clone repository
|
|
28
|
+
await simpleGit().clone('https://github.com/NoelDeMartin/aerogel-template.git', path);
|
|
29
|
+
|
|
30
|
+
// Apply replacements
|
|
31
|
+
const dependencies = this.getDependencies();
|
|
32
|
+
|
|
33
|
+
File.replace(
|
|
34
|
+
resolve(path, 'vite.config.ts'),
|
|
35
|
+
'Aerogel({ name: \'Aerogel\' })',
|
|
36
|
+
`Aerogel({ name: '${this.name}' })`,
|
|
37
|
+
);
|
|
38
|
+
|
|
39
|
+
File.replace(resolve(path, 'src/lang/en.yaml'), 'title: \'App\'', `title: '${this.name}'`);
|
|
40
|
+
|
|
41
|
+
for (const [name, version] of Object.entries(dependencies)) {
|
|
42
|
+
File.replace(resolve(path, 'package.json'), new RegExp(`"${name}": ".*?"`, 'g'), `"${name}": "${version}"`);
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
// Copy template
|
|
46
|
+
Template.instantiate(templatePath('app'), path, { app: { name: this.name } });
|
|
42
47
|
}
|
|
43
48
|
|
|
44
49
|
public edit(): Editor {
|
|
45
50
|
return new Editor();
|
|
46
51
|
}
|
|
47
52
|
|
|
48
|
-
protected getDependencies():
|
|
53
|
+
protected getDependencies(): Record<string, string> {
|
|
49
54
|
const withFilePrefix = <T extends Record<string, string>>(paths: T) =>
|
|
50
55
|
Object.entries(paths).reduce(
|
|
51
56
|
(pathsWithFile, [name, path]) => Object.assign(pathsWithFile, { [name]: `file:${path}` }) as T,
|
|
@@ -54,34 +59,27 @@ export default class App {
|
|
|
54
59
|
|
|
55
60
|
if (this.options.linkedLocal) {
|
|
56
61
|
return withFilePrefix({
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
62
|
+
'@aerogel/cli': packagePath('cli'),
|
|
63
|
+
'@aerogel/core': packagePath('core'),
|
|
64
|
+
'@aerogel/cypress': packagePath('cypress'),
|
|
65
|
+
'@aerogel/plugin-i18n': packagePath('plugin-i18n'),
|
|
66
|
+
'@aerogel/plugin-soukai': packagePath('plugin-soukai'),
|
|
67
|
+
'@aerogel/vite': packagePath('vite'),
|
|
63
68
|
});
|
|
64
69
|
}
|
|
65
70
|
|
|
66
71
|
if (this.options.local) {
|
|
67
72
|
return withFilePrefix({
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
73
|
+
'@aerogel/cli': packagePackPath('cli') ?? packNotFound('cli'),
|
|
74
|
+
'@aerogel/core': packagePackPath('core') ?? packNotFound('core'),
|
|
75
|
+
'@aerogel/cypress': packagePackPath('cypress') ?? packNotFound('cypress'),
|
|
76
|
+
'@aerogel/plugin-i18n': packagePackPath('plugin-i18n') ?? packNotFound('plugin-i18n'),
|
|
77
|
+
'@aerogel/plugin-soukai': packagePackPath('plugin-soukai') ?? packNotFound('plugin-soukai'),
|
|
78
|
+
'@aerogel/vite': packagePackPath('vite') ?? packNotFound('vite'),
|
|
74
79
|
});
|
|
75
80
|
}
|
|
76
81
|
|
|
77
|
-
return {
|
|
78
|
-
aerogelCli: 'next',
|
|
79
|
-
aerogelCore: 'next',
|
|
80
|
-
aerogelCypress: 'next',
|
|
81
|
-
aerogelPluginI18n: 'next',
|
|
82
|
-
aerogelPluginSoukai: 'next',
|
|
83
|
-
aerogelVite: 'next',
|
|
84
|
-
};
|
|
82
|
+
return {};
|
|
85
83
|
}
|
|
86
84
|
|
|
87
85
|
}
|
package/src/lib/Editor.ts
CHANGED
|
@@ -2,9 +2,9 @@ import { arrayFrom } from '@noeldemartin/utils';
|
|
|
2
2
|
import { Project } from 'ts-morph';
|
|
3
3
|
import type { SourceFile } from 'ts-morph';
|
|
4
4
|
|
|
5
|
-
import File from '
|
|
6
|
-
import Log from '
|
|
7
|
-
import Shell from '
|
|
5
|
+
import File from '@aerogel/cli/lib/File';
|
|
6
|
+
import Log from '@aerogel/cli/lib/Log';
|
|
7
|
+
import Shell from '@aerogel/cli/lib/Shell';
|
|
8
8
|
|
|
9
9
|
export class Editor {
|
|
10
10
|
|
|
@@ -16,7 +16,6 @@ export class Editor {
|
|
|
16
16
|
this.modifiedFiles = new Set();
|
|
17
17
|
|
|
18
18
|
this.project.addSourceFilesAtPaths('src/**/*.ts');
|
|
19
|
-
this.project.addSourceFilesAtPaths('tailwind.config.js');
|
|
20
19
|
this.project.addSourceFilesAtPaths('vite.config.ts');
|
|
21
20
|
this.project.addSourceFilesAtPaths('package.json');
|
|
22
21
|
}
|