@aerogel/cli 0.0.0-next.b85327579d32f21c6a9fa21142f0165cdd320d7e → 0.0.0-next.bf95405357e75d2e8b0268a5e8ce7b2b7dd0c895
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 +25 -32
- package/src/cli.ts +28 -8
- package/src/commands/Command.ts +14 -9
- package/src/commands/create.test.ts +12 -3
- package/src/commands/create.ts +15 -12
- package/src/commands/generate-component.test.ts +50 -3
- package/src/commands/generate-component.ts +69 -25
- package/src/commands/generate-model.test.ts +2 -2
- package/src/commands/generate-model.ts +14 -15
- package/src/commands/generate-overrides.ts +85 -0
- package/src/commands/generate-service.test.ts +2 -2
- package/src/commands/generate-service.ts +17 -18
- package/src/commands/info.ts +15 -0
- package/src/commands/install.test.ts +13 -4
- package/src/commands/install.ts +9 -9
- package/src/lib/App.ts +10 -7
- package/src/lib/Editor.ts +19 -13
- package/src/lib/File.mock.ts +7 -11
- package/src/lib/File.ts +3 -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 +3 -3
- package/src/lib/Shell.ts +2 -2
- package/src/lib/Template.ts +24 -17
- package/src/lib/utils/app.ts +3 -3
- package/src/lib/utils/edit.ts +2 -2
- package/src/lib/utils/paths.ts +19 -7
- package/src/plugins/Plugin.ts +46 -12
- package/src/plugins/Solid.ts +47 -41
- package/src/plugins/Soukai.ts +5 -5
- package/src/testing/setup.ts +33 -29
- package/templates/app/.github/workflows/ci.yml +16 -4
- package/templates/app/.nvmrc +1 -1
- package/templates/app/.vscode/launch.json +1 -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 +28 -15
- package/templates/app/src/App.vue +2 -2
- 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 +4 -4
- package/templates/app/tsconfig.json +3 -9
- package/templates/app/vite.config.ts +15 -7
- 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 +1 -1
- 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 -14
- package/src/lib/utils/format.test.ts +0 -33
- package/src/lib/utils/format.ts +0 -38
- package/templates/app/.eslintrc.js +0 -3
- package/templates/app/cypress.config.ts +0 -12
- package/templates/app/postcss.config.js +0 -6
- package/templates/app/prettier.config.js +0 -5
- 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/src/lib/Log.mock.ts
CHANGED
|
@@ -15,23 +15,19 @@ export class LogServiceMock extends LogService {
|
|
|
15
15
|
expect(this.logs, `Expected log to have length ${count}`).toHaveLength(count);
|
|
16
16
|
}
|
|
17
17
|
|
|
18
|
-
protected logLine(message: string): void {
|
|
18
|
+
protected override logLine(message: string): void {
|
|
19
19
|
this.logs.push(message);
|
|
20
20
|
}
|
|
21
21
|
|
|
22
22
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
23
|
-
public fail<T = any>(message: string): T {
|
|
23
|
+
public override fail<T = any>(message: string): T {
|
|
24
24
|
throw new Error(`Fail: ${message}`);
|
|
25
25
|
}
|
|
26
26
|
|
|
27
|
-
|
|
28
|
-
this.logs = [];
|
|
29
|
-
}
|
|
30
|
-
|
|
31
|
-
protected stdout(): void {
|
|
27
|
+
protected override stdout(): void {
|
|
32
28
|
//
|
|
33
29
|
}
|
|
34
30
|
|
|
35
31
|
}
|
|
36
32
|
|
|
37
|
-
export default facade(
|
|
33
|
+
export default facade(LogServiceMock);
|
package/src/lib/Log.test.ts
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
import
|
|
1
|
+
import chalk from 'chalk';
|
|
2
2
|
import { describe, it } from 'vitest';
|
|
3
3
|
|
|
4
|
-
import LogMock from '
|
|
4
|
+
import LogMock from '@aerogel/cli/lib/Log.mock';
|
|
5
5
|
|
|
6
6
|
import Log from './Log';
|
|
7
7
|
|
|
8
|
-
const info = hex('#00ffff');
|
|
8
|
+
const info = chalk.hex('#00ffff');
|
|
9
9
|
|
|
10
10
|
describe('Log', () => {
|
|
11
11
|
|
|
@@ -14,7 +14,7 @@ describe('Log', () => {
|
|
|
14
14
|
Log.info('Foo **bar**');
|
|
15
15
|
|
|
16
16
|
// Assert
|
|
17
|
-
LogMock.expectLogged(info(`Foo ${bold('bar')}`));
|
|
17
|
+
LogMock.expectLogged(info(`Foo ${chalk.bold('bar')}`));
|
|
18
18
|
});
|
|
19
19
|
|
|
20
20
|
it('renders multiline messages', () => {
|
package/src/lib/Log.ts
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
|
+
import chalk from 'chalk';
|
|
2
|
+
import { clearLine, cursorTo } from 'node:readline';
|
|
1
3
|
import { facade, stringMatchAll } from '@noeldemartin/utils';
|
|
2
|
-
import { bold, hex } from 'chalk';
|
|
3
|
-
import { clearLine, cursorTo } from 'readline';
|
|
4
4
|
|
|
5
5
|
export class LogService {
|
|
6
6
|
|
|
7
|
-
protected renderInfo = hex('#00ffff');
|
|
8
|
-
protected renderSuccess = hex('#00ff00');
|
|
9
|
-
protected renderError = hex('#ff0000');
|
|
7
|
+
protected renderInfo = chalk.hex('#00ffff');
|
|
8
|
+
protected renderSuccess = chalk.hex('#00ff00');
|
|
9
|
+
protected renderError = chalk.hex('#ff0000');
|
|
10
10
|
|
|
11
11
|
public async animate<T>(message: string, operation: () => Promise<T>): Promise<T> {
|
|
12
12
|
const updateStdout = (end: string = '', done: boolean = false) => {
|
|
@@ -52,7 +52,7 @@ export class LogService {
|
|
|
52
52
|
const matches = stringMatchAll<2>(message, /\*\*(.*)\*\*/g);
|
|
53
53
|
|
|
54
54
|
for (const match of matches) {
|
|
55
|
-
message = message.replace(match[0], bold(match[1]));
|
|
55
|
+
message = message.replace(match[0], chalk.bold(match[1]));
|
|
56
56
|
}
|
|
57
57
|
|
|
58
58
|
return message;
|
|
@@ -92,4 +92,4 @@ export class LogService {
|
|
|
92
92
|
|
|
93
93
|
}
|
|
94
94
|
|
|
95
|
-
export default facade(
|
|
95
|
+
export default facade(LogService);
|
package/src/lib/Shell.mock.ts
CHANGED
|
@@ -7,8 +7,8 @@ export class ShellServiceMock extends ShellService {
|
|
|
7
7
|
|
|
8
8
|
private history: string[] = [];
|
|
9
9
|
|
|
10
|
-
public async run(command: string): Promise<void> {
|
|
11
|
-
this.history.push(command);
|
|
10
|
+
public override async run(command: string): Promise<void> {
|
|
11
|
+
this.history.push(command.trim());
|
|
12
12
|
}
|
|
13
13
|
|
|
14
14
|
public expectRan(command: string): void {
|
|
@@ -17,4 +17,4 @@ export class ShellServiceMock extends ShellService {
|
|
|
17
17
|
|
|
18
18
|
}
|
|
19
19
|
|
|
20
|
-
export default facade(
|
|
20
|
+
export default facade(ShellServiceMock);
|
package/src/lib/Shell.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { exec } from 'child_process';
|
|
1
|
+
import { exec } from 'node:child_process';
|
|
2
2
|
import { facade } from '@noeldemartin/utils';
|
|
3
3
|
|
|
4
4
|
export class ShellService {
|
|
@@ -25,4 +25,4 @@ export class ShellService {
|
|
|
25
25
|
|
|
26
26
|
}
|
|
27
27
|
|
|
28
|
-
export default facade(
|
|
28
|
+
export default facade(ShellService);
|
package/src/lib/Template.ts
CHANGED
|
@@ -1,12 +1,16 @@
|
|
|
1
|
-
import
|
|
2
|
-
import {
|
|
1
|
+
import Mustache from 'mustache';
|
|
2
|
+
import { readFileSync } from 'node:fs';
|
|
3
3
|
import { toString } from '@noeldemartin/utils';
|
|
4
4
|
|
|
5
|
-
import File from '
|
|
5
|
+
import File from '@aerogel/cli/lib/File';
|
|
6
6
|
|
|
7
7
|
export default class Template {
|
|
8
8
|
|
|
9
|
-
public static instantiate(
|
|
9
|
+
public static instantiate(
|
|
10
|
+
path: string,
|
|
11
|
+
destination: string = './',
|
|
12
|
+
replacements: Record<string, unknown> = {},
|
|
13
|
+
): string[] {
|
|
10
14
|
const template = new Template(path);
|
|
11
15
|
|
|
12
16
|
return template.instantiate(destination, replacements);
|
|
@@ -28,7 +32,7 @@ export default class Template {
|
|
|
28
32
|
const filePath =
|
|
29
33
|
destination + (relativePath.endsWith('.template') ? relativePath.slice(0, -9) : relativePath);
|
|
30
34
|
|
|
31
|
-
File.write(filePath, render(fileContents, replacements, undefined, ['<%', '%>']));
|
|
35
|
+
File.write(filePath, Mustache.render(fileContents, replacements, undefined, ['<%', '%>']));
|
|
32
36
|
files.push(filePath);
|
|
33
37
|
}
|
|
34
38
|
|
|
@@ -39,18 +43,21 @@ export default class Template {
|
|
|
39
43
|
replacements: Record<string, unknown>,
|
|
40
44
|
prefix: string = '',
|
|
41
45
|
): Record<string, string> {
|
|
42
|
-
return Object.entries(replacements).reduce(
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
46
|
+
return Object.entries(replacements).reduce(
|
|
47
|
+
(filenameReplacements, [key, value]) => {
|
|
48
|
+
if (typeof value === 'object') {
|
|
49
|
+
Object.assign(
|
|
50
|
+
filenameReplacements,
|
|
51
|
+
this.getFilenameReplacements(value as Record<string, unknown>, `${key}.`),
|
|
52
|
+
);
|
|
53
|
+
} else {
|
|
54
|
+
filenameReplacements[`[${prefix}${key}]`] = toString(value);
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
return filenameReplacements;
|
|
58
|
+
},
|
|
59
|
+
{} as Record<string, string>,
|
|
60
|
+
);
|
|
54
61
|
}
|
|
55
62
|
|
|
56
63
|
}
|
package/src/lib/utils/app.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import App from '
|
|
2
|
-
import File from '
|
|
1
|
+
import App from '@aerogel/cli/lib/App';
|
|
2
|
+
import File from '@aerogel/cli/lib/File';
|
|
3
3
|
|
|
4
4
|
export function app(): App {
|
|
5
5
|
// TODO parse app name
|
|
@@ -7,7 +7,7 @@ export function app(): App {
|
|
|
7
7
|
}
|
|
8
8
|
|
|
9
9
|
export function isLocalApp(): boolean {
|
|
10
|
-
return File.contains('package.json', 'file');
|
|
10
|
+
return File.contains('package.json', '"@aerogel/core": "file:');
|
|
11
11
|
}
|
|
12
12
|
|
|
13
13
|
export function isLinkedLocalApp(): boolean {
|
package/src/lib/utils/edit.ts
CHANGED
|
@@ -23,8 +23,8 @@ export function findDescendant<T extends Node>(
|
|
|
23
23
|
const skipKinds = arrayFrom(options.skip ?? []);
|
|
24
24
|
|
|
25
25
|
return node.forEachDescendant((descendant, traversal) => {
|
|
26
|
-
if (guard(descendant) && validate(descendant)) {
|
|
27
|
-
return descendant;
|
|
26
|
+
if (guard(descendant) && validate(descendant as T)) {
|
|
27
|
+
return descendant as T;
|
|
28
28
|
}
|
|
29
29
|
|
|
30
30
|
const descendantKind = descendant.getKind();
|
package/src/lib/utils/paths.ts
CHANGED
|
@@ -1,16 +1,24 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { URL, fileURLToPath } from 'node:url';
|
|
2
2
|
import { stringMatch } from '@noeldemartin/utils';
|
|
3
|
+
import { resolve } from 'node:path';
|
|
3
4
|
|
|
4
|
-
import File from '
|
|
5
|
-
import Log from '
|
|
5
|
+
import File from '@aerogel/cli/lib/File';
|
|
6
|
+
import Log from '@aerogel/cli/lib/Log';
|
|
6
7
|
|
|
7
8
|
export function basePath(path: string = ''): string {
|
|
8
|
-
if (
|
|
9
|
-
|
|
9
|
+
if (
|
|
10
|
+
File.contains(
|
|
11
|
+
fileURLToPath(new URL(/* @vite-ignore */ '../../../package.json', import.meta.url)),
|
|
12
|
+
'"packages/create-aerogel"',
|
|
13
|
+
)
|
|
14
|
+
) {
|
|
15
|
+
return resolve(fileURLToPath(new URL(/* @vite-ignore */ '../', import.meta.url)), path);
|
|
10
16
|
}
|
|
11
17
|
|
|
12
|
-
const packageJson = File.read(
|
|
13
|
-
|
|
18
|
+
const packageJson = File.read(
|
|
19
|
+
fileURLToPath(new URL(/* @vite-ignore */ '../../../../package.json', import.meta.url)),
|
|
20
|
+
);
|
|
21
|
+
const matches = stringMatch<2>(packageJson ?? '', /"@aerogel\/core": "file:(.*)\/aerogel-core-[\d.]*\.tgz"/);
|
|
14
22
|
const cliPath = matches?.[1] ?? Log.fail<string>('Could not determine base path');
|
|
15
23
|
|
|
16
24
|
return resolve(cliPath, path);
|
|
@@ -28,3 +36,7 @@ export function packagePackPath(packageName: string): string | null {
|
|
|
28
36
|
export function packagePath(packageName: string): string {
|
|
29
37
|
return basePath(`../${packageName}`);
|
|
30
38
|
}
|
|
39
|
+
|
|
40
|
+
export function templatePath(name: string): string {
|
|
41
|
+
return fileURLToPath(new URL(/* @vite-ignore */ `../templates/${name}`, import.meta.url));
|
|
42
|
+
}
|
package/src/plugins/Plugin.ts
CHANGED
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
import { Node, SyntaxKind } from 'ts-morph';
|
|
2
2
|
import type { ArrayLiteralExpression, ImportDeclarationStructure, OptionalKind, SourceFile } from 'ts-morph';
|
|
3
3
|
|
|
4
|
-
import Log from '
|
|
5
|
-
import Shell from '
|
|
6
|
-
import File from '
|
|
7
|
-
import { app, isLinkedLocalApp, isLocalApp } from '
|
|
8
|
-
import { editFiles, findDescendant, when } from '
|
|
9
|
-
import { packNotFound, packagePackPath, packagePath } from '
|
|
10
|
-
import type { Editor } from '
|
|
4
|
+
import Log from '@aerogel/cli/lib/Log';
|
|
5
|
+
import Shell from '@aerogel/cli/lib/Shell';
|
|
6
|
+
import File from '@aerogel/cli/lib/File';
|
|
7
|
+
import { app, isLinkedLocalApp, isLocalApp } from '@aerogel/cli/lib/utils/app';
|
|
8
|
+
import { editFiles, findDescendant, when } from '@aerogel/cli/lib/utils/edit';
|
|
9
|
+
import { packNotFound, packagePackPath, packagePath } from '@aerogel/cli/lib/utils/paths';
|
|
10
|
+
import type { Editor } from '@aerogel/cli/lib/Editor';
|
|
11
11
|
|
|
12
12
|
export default abstract class Plugin {
|
|
13
13
|
|
|
@@ -20,6 +20,7 @@ export default abstract class Plugin {
|
|
|
20
20
|
public async install(): Promise<void> {
|
|
21
21
|
this.assertNotInstalled();
|
|
22
22
|
|
|
23
|
+
await this.beforeInstall();
|
|
23
24
|
await this.installDependencies();
|
|
24
25
|
|
|
25
26
|
if (editFiles()) {
|
|
@@ -29,6 +30,8 @@ export default abstract class Plugin {
|
|
|
29
30
|
await editor.format();
|
|
30
31
|
}
|
|
31
32
|
|
|
33
|
+
await this.afterInstall();
|
|
34
|
+
|
|
32
35
|
Log.info(`Plugin ${this.name} installed!`);
|
|
33
36
|
}
|
|
34
37
|
|
|
@@ -38,6 +41,14 @@ export default abstract class Plugin {
|
|
|
38
41
|
}
|
|
39
42
|
}
|
|
40
43
|
|
|
44
|
+
protected async beforeInstall(): Promise<void> {
|
|
45
|
+
// Placeholder for overrides, don't place any functionality here.
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
protected async afterInstall(): Promise<void> {
|
|
49
|
+
// Placeholder for overrides, don't place any functionality here.
|
|
50
|
+
}
|
|
51
|
+
|
|
41
52
|
protected async installDependencies(): Promise<void> {
|
|
42
53
|
await Log.animate('Installing plugin dependencies', async () => {
|
|
43
54
|
await this.installNpmDependencies();
|
|
@@ -45,12 +56,16 @@ export default abstract class Plugin {
|
|
|
45
56
|
}
|
|
46
57
|
|
|
47
58
|
protected async updateFiles(editor: Editor): Promise<void> {
|
|
48
|
-
|
|
59
|
+
if (!this.isForDevelopment()) {
|
|
60
|
+
await this.updateBootstrapConfig(editor);
|
|
61
|
+
}
|
|
49
62
|
}
|
|
50
63
|
|
|
51
64
|
protected async installNpmDependencies(): Promise<void> {
|
|
65
|
+
const flags = this.isForDevelopment() ? '--save-dev' : '';
|
|
66
|
+
|
|
52
67
|
if (isLinkedLocalApp()) {
|
|
53
|
-
await Shell.run(`npm install file:${packagePath(this.getLocalPackageName())}`);
|
|
68
|
+
await Shell.run(`npm install file:${packagePath(this.getLocalPackageName())} ${flags}`);
|
|
54
69
|
|
|
55
70
|
return;
|
|
56
71
|
}
|
|
@@ -58,12 +73,12 @@ export default abstract class Plugin {
|
|
|
58
73
|
if (isLocalApp()) {
|
|
59
74
|
const packPath = packagePackPath(this.getLocalPackageName()) ?? packNotFound(this.getLocalPackageName());
|
|
60
75
|
|
|
61
|
-
await Shell.run(`npm install file:${packPath}`);
|
|
76
|
+
await Shell.run(`npm install file:${packPath} ${flags}`);
|
|
62
77
|
|
|
63
78
|
return;
|
|
64
79
|
}
|
|
65
80
|
|
|
66
|
-
await Shell.run(`npm install ${this.getNpmPackageName()}@next`);
|
|
81
|
+
await Shell.run(`npm install ${this.getNpmPackageName()}@next --save-exact ${flags}`);
|
|
67
82
|
}
|
|
68
83
|
|
|
69
84
|
protected async updateBootstrapConfig(editor: Editor): Promise<void> {
|
|
@@ -89,7 +104,7 @@ export default abstract class Plugin {
|
|
|
89
104
|
protected getBootstrapPluginsDeclaration(mainConfig: SourceFile): ArrayLiteralExpression | null {
|
|
90
105
|
const bootstrapAppCall = findDescendant(mainConfig, {
|
|
91
106
|
guard: Node.isCallExpression,
|
|
92
|
-
validate: (callExpression) => callExpression.getExpression().getText() === '
|
|
107
|
+
validate: (callExpression) => callExpression.getExpression().getText() === 'bootstrap',
|
|
93
108
|
skip: SyntaxKind.ImportDeclaration,
|
|
94
109
|
});
|
|
95
110
|
const bootstrapOptions = bootstrapAppCall?.getArguments()[1];
|
|
@@ -103,6 +118,21 @@ export default abstract class Plugin {
|
|
|
103
118
|
return pluginsArray;
|
|
104
119
|
}
|
|
105
120
|
|
|
121
|
+
protected getTailwindContentArray(tailwindConfig: SourceFile): ArrayLiteralExpression | null {
|
|
122
|
+
const contentAssignment = findDescendant(tailwindConfig, {
|
|
123
|
+
guard: Node.isPropertyAssignment,
|
|
124
|
+
validate: (propertyAssignment) => propertyAssignment.getName() === 'content',
|
|
125
|
+
skip: SyntaxKind.JSDoc,
|
|
126
|
+
});
|
|
127
|
+
const contentArray = contentAssignment?.getInitializer();
|
|
128
|
+
|
|
129
|
+
if (!Node.isArrayLiteralExpression(contentArray)) {
|
|
130
|
+
return null;
|
|
131
|
+
}
|
|
132
|
+
|
|
133
|
+
return contentArray;
|
|
134
|
+
}
|
|
135
|
+
|
|
106
136
|
protected getBootstrapImport(): OptionalKind<ImportDeclarationStructure> {
|
|
107
137
|
return {
|
|
108
138
|
defaultImport: this.name,
|
|
@@ -118,6 +148,10 @@ export default abstract class Plugin {
|
|
|
118
148
|
return `plugin-${this.name}`;
|
|
119
149
|
}
|
|
120
150
|
|
|
151
|
+
protected isForDevelopment(): boolean {
|
|
152
|
+
return false;
|
|
153
|
+
}
|
|
154
|
+
|
|
121
155
|
protected getBootstrapConfig(): string {
|
|
122
156
|
return `${this.name}()`;
|
|
123
157
|
}
|
package/src/plugins/Solid.ts
CHANGED
|
@@ -1,13 +1,8 @@
|
|
|
1
|
-
import
|
|
2
|
-
import
|
|
3
|
-
|
|
4
|
-
import
|
|
5
|
-
import
|
|
6
|
-
import Log from '@/lib/Log';
|
|
7
|
-
import { findDescendant } from '@/lib/utils/edit';
|
|
8
|
-
import { isLinkedLocalApp } from '@/lib/utils/app';
|
|
9
|
-
import { packagePath } from '@/lib/utils/paths';
|
|
10
|
-
import type { Editor } from '@/lib/Editor';
|
|
1
|
+
import File from '@aerogel/cli/lib/File';
|
|
2
|
+
import Log from '@aerogel/cli/lib/Log';
|
|
3
|
+
import Plugin from '@aerogel/cli/plugins/Plugin';
|
|
4
|
+
import Shell from '@aerogel/cli/lib/Shell';
|
|
5
|
+
import type { Editor } from '@aerogel/cli/lib/Editor';
|
|
11
6
|
|
|
12
7
|
export class Solid extends Plugin {
|
|
13
8
|
|
|
@@ -15,51 +10,62 @@ export class Solid extends Plugin {
|
|
|
15
10
|
super('solid');
|
|
16
11
|
}
|
|
17
12
|
|
|
18
|
-
protected async updateFiles(editor: Editor): Promise<void> {
|
|
19
|
-
await this.
|
|
13
|
+
protected override async updateFiles(editor: Editor): Promise<void> {
|
|
14
|
+
await this.updateNpmScripts(editor);
|
|
15
|
+
await this.updateGitIgnore();
|
|
20
16
|
await super.updateFiles(editor);
|
|
21
17
|
}
|
|
22
18
|
|
|
23
|
-
protected async installNpmDependencies(): Promise<void> {
|
|
24
|
-
await Shell.run('npm install soukai-solid@next');
|
|
19
|
+
protected override async installNpmDependencies(): Promise<void> {
|
|
20
|
+
await Shell.run('npm install soukai-solid@next --save-exact');
|
|
21
|
+
await Shell.run('npm install @noeldemartin/solid-utils@next --save-exact');
|
|
22
|
+
await Shell.run('npm install @solid/community-server@7.1.6 --save-dev -E');
|
|
25
23
|
await super.installNpmDependencies();
|
|
26
24
|
}
|
|
27
25
|
|
|
28
|
-
protected async
|
|
29
|
-
|
|
30
|
-
const tailwindConfig = editor.requireSourceFile('tailwind.config.js');
|
|
31
|
-
const contentArray = this.getTailwindContentArray(tailwindConfig);
|
|
32
|
-
const contentValue = isLinkedLocalApp()
|
|
33
|
-
? `'${packagePath('plugin-solid')}/dist/**/*.js'`
|
|
34
|
-
: '\'./node_modules/@aerogel/plugin-solid/dist/**/*.js\'';
|
|
26
|
+
protected async updateNpmScripts(editor: Editor): Promise<void> {
|
|
27
|
+
Log.info('Updating npm scripts...');
|
|
35
28
|
|
|
36
|
-
|
|
37
|
-
return Log.fail(`
|
|
38
|
-
Could not find content array in tailwind config, please add the following manually:
|
|
29
|
+
const packageJson = File.read('package.json');
|
|
39
30
|
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
31
|
+
if (!packageJson) {
|
|
32
|
+
return Log.fail('Could not find package.json file');
|
|
33
|
+
}
|
|
43
34
|
|
|
44
|
-
|
|
35
|
+
File.write(
|
|
36
|
+
'package.json',
|
|
37
|
+
packageJson
|
|
38
|
+
.replace(
|
|
39
|
+
'"cy:dev": "concurrently --kill-others \\"npm run test:serve-app\\" \\"npm run cy:open\\"",',
|
|
40
|
+
'"cy:dev": "concurrently --kill-others ' +
|
|
41
|
+
'\\"npm run test:serve-app\\" \\"npm run test:serve-pod\\" \\"npm run cy:open\\"",',
|
|
42
|
+
)
|
|
43
|
+
.replace(
|
|
44
|
+
'"cy:test": "start-server-and-test test:serve-app http-get://localhost:5001 cy:run",',
|
|
45
|
+
'"cy:test": "start-server-and-test ' +
|
|
46
|
+
'test:serve-app http-get://localhost:5001 test:serve-pod http-get://localhost:3000 cy:run",',
|
|
47
|
+
)
|
|
48
|
+
.replace(
|
|
49
|
+
'"dev": "vite",',
|
|
50
|
+
'"dev": "vite",\n' +
|
|
51
|
+
'"dev:serve-pod": "community-solid-server -c @css:config/file.json -f ./solid",',
|
|
52
|
+
)
|
|
53
|
+
.replace(
|
|
54
|
+
'"test:serve-app": "vite --port 5001 --mode testing"',
|
|
55
|
+
'"test:serve-app": "vite --port 5001 --mode testing",\n' +
|
|
56
|
+
'"test:serve-pod": "community-solid-server -l warn"',
|
|
57
|
+
),
|
|
58
|
+
);
|
|
45
59
|
|
|
46
|
-
|
|
47
|
-
});
|
|
60
|
+
editor.addModifiedFile('package.json');
|
|
48
61
|
}
|
|
49
62
|
|
|
50
|
-
protected
|
|
51
|
-
|
|
52
|
-
guard: Node.isPropertyAssignment,
|
|
53
|
-
validate: (propertyAssignment) => propertyAssignment.getName() === 'content',
|
|
54
|
-
skip: SyntaxKind.JSDoc,
|
|
55
|
-
});
|
|
56
|
-
const contentArray = contentAssignment?.getInitializer();
|
|
63
|
+
protected async updateGitIgnore(): Promise<void> {
|
|
64
|
+
Log.info('Updating .gitignore');
|
|
57
65
|
|
|
58
|
-
|
|
59
|
-
return null;
|
|
60
|
-
}
|
|
66
|
+
const gitignore = File.read('.gitignore') ?? '';
|
|
61
67
|
|
|
62
|
-
|
|
68
|
+
File.write('.gitignore', `${gitignore}/solid\n`);
|
|
63
69
|
}
|
|
64
70
|
|
|
65
71
|
}
|
package/src/plugins/Soukai.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import Plugin from '
|
|
2
|
-
import Shell from '
|
|
1
|
+
import Plugin from '@aerogel/cli/plugins/Plugin';
|
|
2
|
+
import Shell from '@aerogel/cli/lib/Shell';
|
|
3
3
|
|
|
4
4
|
export class Soukai extends Plugin {
|
|
5
5
|
|
|
@@ -7,12 +7,12 @@ export class Soukai extends Plugin {
|
|
|
7
7
|
super('soukai');
|
|
8
8
|
}
|
|
9
9
|
|
|
10
|
-
protected async installNpmDependencies(): Promise<void> {
|
|
11
|
-
await Shell.run('npm install soukai@next');
|
|
10
|
+
protected override async installNpmDependencies(): Promise<void> {
|
|
11
|
+
await Shell.run('npm install soukai@next --save-exact');
|
|
12
12
|
await super.installNpmDependencies();
|
|
13
13
|
}
|
|
14
14
|
|
|
15
|
-
protected getBootstrapConfig(): string {
|
|
15
|
+
protected override getBootstrapConfig(): string {
|
|
16
16
|
return 'soukai({ models: import.meta.glob(\'@/models/*\', { eager: true }) })';
|
|
17
17
|
}
|
|
18
18
|
|
package/src/testing/setup.ts
CHANGED
|
@@ -1,31 +1,36 @@
|
|
|
1
|
-
import { beforeEach, vi } from 'vitest';
|
|
2
|
-
import { resolve } from 'path';
|
|
3
|
-
import {
|
|
1
|
+
import { beforeAll, beforeEach, vi } from 'vitest';
|
|
2
|
+
import { resolve } from 'node:path';
|
|
3
|
+
import { setupFacadeMocks } from '@noeldemartin/testing';
|
|
4
4
|
|
|
5
|
-
import
|
|
6
|
-
import
|
|
7
|
-
import
|
|
8
|
-
import
|
|
9
|
-
import
|
|
10
|
-
import
|
|
5
|
+
import ShellMock from '@aerogel/cli/lib/Shell.mock';
|
|
6
|
+
import File from '@aerogel/cli/lib/File';
|
|
7
|
+
import FileMock from '@aerogel/cli/lib/File.mock';
|
|
8
|
+
import Log from '@aerogel/cli/lib/Log';
|
|
9
|
+
import LogMock from '@aerogel/cli/lib/Log.mock';
|
|
10
|
+
import Shell from '@aerogel/cli/lib/Shell';
|
|
11
11
|
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
12
|
+
beforeAll(() => {
|
|
13
|
+
File.setMockFacade(FileMock);
|
|
14
|
+
Log.setMockFacade(LogMock);
|
|
15
|
+
Shell.setMockFacade(ShellMock);
|
|
16
|
+
});
|
|
17
17
|
|
|
18
18
|
beforeEach(() => {
|
|
19
|
-
FileMock.reset();
|
|
20
|
-
LogMock.reset();
|
|
21
|
-
|
|
22
19
|
File.mock();
|
|
23
20
|
Log.mock();
|
|
24
21
|
Shell.mock();
|
|
25
22
|
});
|
|
26
23
|
|
|
27
|
-
vi.mock('
|
|
28
|
-
const original = (await vi.importActual('
|
|
24
|
+
vi.mock('@noeldemartin/utils', async () => {
|
|
25
|
+
const original = (await vi.importActual('@noeldemartin/utils')) as object;
|
|
26
|
+
|
|
27
|
+
setupFacadeMocks();
|
|
28
|
+
|
|
29
|
+
return original;
|
|
30
|
+
});
|
|
31
|
+
|
|
32
|
+
vi.mock('@aerogel/cli/lib/utils/app', async () => {
|
|
33
|
+
const original = (await vi.importActual('@aerogel/cli/lib/utils/app')) as object;
|
|
29
34
|
|
|
30
35
|
return {
|
|
31
36
|
...original,
|
|
@@ -34,8 +39,8 @@ vi.mock('@/lib/utils/app', async () => {
|
|
|
34
39
|
};
|
|
35
40
|
});
|
|
36
41
|
|
|
37
|
-
vi.mock('
|
|
38
|
-
const original = (await vi.importActual('
|
|
42
|
+
vi.mock('@aerogel/cli/lib/utils/edit', async () => {
|
|
43
|
+
const original = (await vi.importActual('@aerogel/cli/lib/utils/edit')) as object;
|
|
39
44
|
|
|
40
45
|
return {
|
|
41
46
|
...original,
|
|
@@ -44,8 +49,8 @@ vi.mock('@/lib/utils/edit', async () => {
|
|
|
44
49
|
});
|
|
45
50
|
|
|
46
51
|
// TODO find out why these need to be mocked
|
|
47
|
-
vi.mock('
|
|
48
|
-
const original = (await vi.importActual('
|
|
52
|
+
vi.mock('@aerogel/cli/lib/utils/paths', async () => {
|
|
53
|
+
const original = (await vi.importActual('@aerogel/cli/lib/utils/paths')) as object;
|
|
49
54
|
|
|
50
55
|
function basePath(path: string = '') {
|
|
51
56
|
return resolve(__dirname, '../../', path);
|
|
@@ -55,15 +60,14 @@ vi.mock('@/lib/utils/paths', async () => {
|
|
|
55
60
|
return basePath(`../${packageName}`);
|
|
56
61
|
}
|
|
57
62
|
|
|
63
|
+
function templatePath(name: string = '') {
|
|
64
|
+
return resolve(__dirname, `../../templates/${name}`);
|
|
65
|
+
}
|
|
66
|
+
|
|
58
67
|
return {
|
|
59
68
|
...original,
|
|
60
69
|
basePath,
|
|
61
70
|
packagePath,
|
|
71
|
+
templatePath,
|
|
62
72
|
};
|
|
63
73
|
});
|
|
64
|
-
|
|
65
|
-
vi.mock('mustache', async () => {
|
|
66
|
-
const mustache = (await vi.importActual('mustache')) as { default: unknown };
|
|
67
|
-
|
|
68
|
-
return mustache.default;
|
|
69
|
-
});
|
|
@@ -6,12 +6,24 @@ jobs:
|
|
|
6
6
|
ci:
|
|
7
7
|
runs-on: ubuntu-latest
|
|
8
8
|
steps:
|
|
9
|
-
- uses: actions/checkout@
|
|
10
|
-
- uses: actions/setup-node@
|
|
9
|
+
- uses: actions/checkout@v4
|
|
10
|
+
- uses: actions/setup-node@v4
|
|
11
11
|
with:
|
|
12
12
|
node-version-file: '.nvmrc'
|
|
13
13
|
- run: npm ci
|
|
14
14
|
- run: npm run lint
|
|
15
|
-
- run: npm run test:ci
|
|
16
|
-
- run: npm run cy:test
|
|
17
15
|
- run: npm run build
|
|
16
|
+
- run: npm run test:ci
|
|
17
|
+
- run: npm run cy:test-snapshots:ci
|
|
18
|
+
- name: Upload Cypress screenshots
|
|
19
|
+
uses: actions/upload-artifact@v4
|
|
20
|
+
if: ${{ failure() }}
|
|
21
|
+
with:
|
|
22
|
+
name: cypress_screenshots
|
|
23
|
+
path: cypress/screenshots
|
|
24
|
+
- name: Upload Cypress snapshots
|
|
25
|
+
uses: actions/upload-artifact@v4
|
|
26
|
+
if: ${{ failure() }}
|
|
27
|
+
with:
|
|
28
|
+
name: cypress_snapshots
|
|
29
|
+
path: cypress/snapshots
|
package/templates/app/.nvmrc
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
|
|
1
|
+
v22.9.0
|