@aerogel/cli 0.0.0-next.c8f032a868370824898e171969aec1bb6827688e → 0.0.0-next.d824b40e5d06757cd9f47c9f771d916185df4f05

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.
Files changed (50) hide show
  1. package/dist/aerogel-cli.cjs.js +1 -1
  2. package/dist/aerogel-cli.cjs.js.map +1 -1
  3. package/dist/aerogel-cli.esm.js +1 -1
  4. package/dist/aerogel-cli.esm.js.map +1 -1
  5. package/package.json +4 -3
  6. package/src/cli.ts +4 -0
  7. package/src/commands/create.test.ts +23 -4
  8. package/src/commands/create.ts +30 -12
  9. package/src/commands/generate-component.test.ts +12 -1
  10. package/src/commands/generate-component.ts +127 -20
  11. package/src/commands/generate-model.test.ts +16 -5
  12. package/src/commands/generate-model.ts +38 -12
  13. package/src/commands/generate-service.test.ts +21 -0
  14. package/src/commands/generate-service.ts +152 -0
  15. package/src/commands/install.test.ts +18 -0
  16. package/src/commands/install.ts +32 -0
  17. package/src/lib/App.ts +65 -3
  18. package/src/lib/Editor.ts +56 -0
  19. package/src/lib/File.ts +10 -0
  20. package/src/lib/Log.mock.ts +13 -4
  21. package/src/lib/Log.test.ts +19 -3
  22. package/src/lib/Log.ts +36 -20
  23. package/src/lib/Template.ts +4 -3
  24. package/src/lib/utils/app.ts +15 -0
  25. package/src/lib/utils/edit.ts +44 -0
  26. package/src/lib/{utils.test.ts → utils/format.test.ts} +2 -2
  27. package/src/lib/{utils.ts → utils/format.ts} +0 -6
  28. package/src/lib/utils/paths.ts +34 -0
  29. package/src/plugins/Plugin.ts +125 -0
  30. package/src/plugins/Solid.ts +114 -0
  31. package/src/plugins/Soukai.ts +19 -0
  32. package/src/testing/setup.ts +38 -6
  33. package/templates/app/.eslintrc.js +3 -0
  34. package/templates/app/.github/workflows/ci.yml +14 -2
  35. package/templates/app/.gitignore.template +2 -0
  36. package/templates/app/.vscode/launch.json +16 -0
  37. package/templates/app/.vscode/settings.json +10 -0
  38. package/templates/app/README.md +3 -0
  39. package/templates/app/cypress.config.ts +8 -0
  40. package/templates/app/index.html +1 -1
  41. package/templates/app/package.json +21 -10
  42. package/templates/app/prettier.config.js +5 -0
  43. package/templates/app/src/App.vue +3 -1
  44. package/templates/app/src/main.ts +5 -1
  45. package/templates/app/src/types/globals.d.ts +0 -1
  46. package/templates/app/tailwind.config.js +1 -1
  47. package/templates/app/tsconfig.json +1 -0
  48. package/templates/app/vite.config.ts +12 -5
  49. package/templates/service/[service.name].ts +8 -0
  50. package/noeldemartin.config.js +0 -4
@@ -0,0 +1,114 @@
1
+ import { Node, SyntaxKind } from 'ts-morph';
2
+ import type { ArrayLiteralExpression, SourceFile } from 'ts-morph';
3
+
4
+ import File from '@/lib/File';
5
+ import Log from '@/lib/Log';
6
+ import Plugin from '@/plugins/Plugin';
7
+ import Shell from '@/lib/Shell';
8
+ import { findDescendant } from '@/lib/utils/edit';
9
+ import { isLinkedLocalApp } from '@/lib/utils/app';
10
+ import { packagePath } from '@/lib/utils/paths';
11
+ import type { Editor } from '@/lib/Editor';
12
+
13
+ export class Solid extends Plugin {
14
+
15
+ constructor() {
16
+ super('solid');
17
+ }
18
+
19
+ protected async updateFiles(editor: Editor): Promise<void> {
20
+ await this.updateTailwindConfig(editor);
21
+ await this.updateNpmScripts(editor);
22
+ await this.updateGitIgnore();
23
+ await super.updateFiles(editor);
24
+ }
25
+
26
+ protected async installNpmDependencies(): Promise<void> {
27
+ await Shell.run('npm install soukai-solid@next --save-exact');
28
+ await Shell.run('npm install @solid/community-server@7 --save');
29
+ await super.installNpmDependencies();
30
+ }
31
+
32
+ protected async updateTailwindConfig(editor: Editor): Promise<void> {
33
+ await Log.animate('Updating tailwind configuration', async () => {
34
+ const tailwindConfig = editor.requireSourceFile('tailwind.config.js');
35
+ const contentArray = this.getTailwindContentArray(tailwindConfig);
36
+ const contentValue = isLinkedLocalApp()
37
+ ? `'${packagePath('plugin-solid')}/dist/**/*.js'`
38
+ : '\'./node_modules/@aerogel/plugin-solid/dist/**/*.js\'';
39
+
40
+ if (!contentArray) {
41
+ return Log.fail(`
42
+ Could not find content array in tailwind config, please add the following manually:
43
+
44
+ ${contentValue}
45
+ `);
46
+ }
47
+
48
+ contentArray.addElement(contentValue);
49
+
50
+ await editor.save(tailwindConfig);
51
+ });
52
+ }
53
+
54
+ protected async updateNpmScripts(editor: Editor): Promise<void> {
55
+ Log.info('Updating npm scripts...');
56
+
57
+ const packageJson = File.read('package.json');
58
+
59
+ if (!packageJson) {
60
+ return Log.fail('Could not find package.json file');
61
+ }
62
+
63
+ File.write(
64
+ 'package.json',
65
+ packageJson
66
+ .replace(
67
+ '"cy:dev": "concurrently --kill-others \\"npm run test:serve-app\\" \\"npm run cy:open\\"",',
68
+ '"cy:dev": "concurrently --kill-others ' +
69
+ '\\"npm run test:serve-app\\" \\"npm run test:serve-pod\\" \\"npm run cy:open\\"",',
70
+ )
71
+ .replace(
72
+ '"cy:test": "start-server-and-test test:serve-app http-get://localhost:5001 cy:run",',
73
+ '"cy:test": "start-server-and-test ' +
74
+ 'test:serve-app http-get://localhost:5001 test:serve-pod http-get://localhost:4000 cy:run",',
75
+ )
76
+ .replace(
77
+ '"dev": "vite",',
78
+ '"dev": "vite",\n' +
79
+ '"dev:serve-pod": "community-solid-server -c @css:config/file.json -p 4000 -f ./solid-data",',
80
+ )
81
+ .replace(
82
+ '"test:serve-app": "vite --port 5001"',
83
+ '"test:serve-app": "vite --port 5001",\n' +
84
+ '"test:serve-pod": "community-solid-server -p 4000 -l warn"',
85
+ ),
86
+ );
87
+
88
+ editor.addModifiedFile('package.json');
89
+ }
90
+
91
+ protected async updateGitIgnore(): Promise<void> {
92
+ Log.info('Updating .gitignore');
93
+
94
+ const gitignore = File.read('.gitignore') ?? '';
95
+
96
+ File.write('.gitignore', `${gitignore}/solid-data\n`);
97
+ }
98
+
99
+ protected getTailwindContentArray(tailwindConfig: SourceFile): ArrayLiteralExpression | null {
100
+ const contentAssignment = findDescendant(tailwindConfig, {
101
+ guard: Node.isPropertyAssignment,
102
+ validate: (propertyAssignment) => propertyAssignment.getName() === 'content',
103
+ skip: SyntaxKind.JSDoc,
104
+ });
105
+ const contentArray = contentAssignment?.getInitializer();
106
+
107
+ if (!Node.isArrayLiteralExpression(contentArray)) {
108
+ return null;
109
+ }
110
+
111
+ return contentArray;
112
+ }
113
+
114
+ }
@@ -0,0 +1,19 @@
1
+ import Plugin from '@/plugins/Plugin';
2
+ import Shell from '@/lib/Shell';
3
+
4
+ export class Soukai extends Plugin {
5
+
6
+ constructor() {
7
+ super('soukai');
8
+ }
9
+
10
+ protected async installNpmDependencies(): Promise<void> {
11
+ await Shell.run('npm install soukai@next --save-exact');
12
+ await super.installNpmDependencies();
13
+ }
14
+
15
+ protected getBootstrapConfig(): string {
16
+ return 'soukai({ models: import.meta.glob(\'@/models/*\', { eager: true }) })';
17
+ }
18
+
19
+ }
@@ -17,21 +17,53 @@ Shell.setMockInstance(ShellMock);
17
17
 
18
18
  beforeEach(() => {
19
19
  FileMock.reset();
20
+ LogMock.reset();
21
+
20
22
  File.mock();
21
23
  Log.mock();
22
24
  Shell.mock();
23
25
  });
24
26
 
27
+ vi.mock('@/lib/utils/app', async () => {
28
+ const original = (await vi.importActual('@/lib/utils/app')) as object;
29
+
30
+ return {
31
+ ...original,
32
+ isLocalApp: () => false,
33
+ isLinkedLocalApp: () => false,
34
+ };
35
+ });
36
+
37
+ vi.mock('@/lib/utils/edit', async () => {
38
+ const original = (await vi.importActual('@/lib/utils/edit')) as object;
39
+
40
+ return {
41
+ ...original,
42
+ editFiles: () => false,
43
+ };
44
+ });
45
+
25
46
  // TODO find out why these need to be mocked
47
+ vi.mock('@/lib/utils/paths', async () => {
48
+ const original = (await vi.importActual('@/lib/utils/paths')) as object;
49
+
50
+ function basePath(path: string = '') {
51
+ return resolve(__dirname, '../../', path);
52
+ }
53
+
54
+ function packagePath(packageName: string) {
55
+ return basePath(`../${packageName}`);
56
+ }
26
57
 
27
- vi.mock('@/lib/utils', async () => {
28
- const utils = (await vi.importActual('@/lib/utils')) as object;
58
+ function templatePath(name: string = '') {
59
+ return resolve(__dirname, `../../templates/${name}`);
60
+ }
29
61
 
30
62
  return {
31
- ...utils,
32
- basePath(path: string) {
33
- return resolve(__dirname, '../../', path);
34
- },
63
+ ...original,
64
+ basePath,
65
+ packagePath,
66
+ templatePath,
35
67
  };
36
68
  });
37
69
 
@@ -0,0 +1,3 @@
1
+ module.exports = {
2
+ extends: ['@noeldemartin/eslint-config-vue'],
3
+ };
@@ -12,6 +12,18 @@ jobs:
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@v3
20
+ if: ${{ failure() }}
21
+ with:
22
+ name: cypress_screenshots
23
+ path: cypress/screenshots
24
+ - name: Upload Cypress snapshots
25
+ uses: actions/upload-artifact@v3
26
+ if: ${{ failure() }}
27
+ with:
28
+ name: cypress_snapshots
29
+ path: cypress/snapshots
@@ -0,0 +1,2 @@
1
+ /dist
2
+ /node_modules
@@ -0,0 +1,16 @@
1
+ {
2
+ "version": "0.2.0",
3
+ "configurations": [
4
+ {
5
+ "type": "node",
6
+ "request": "launch",
7
+ "name": "Debug Current Test File",
8
+ "autoAttachChildProcesses": true,
9
+ "skipFiles": ["<node_internals>/**", "**/node_modules/**"],
10
+ "program": "${workspaceRoot}/node_modules/vitest/vitest.mjs",
11
+ "args": ["run", "${fileBasenameNoExtension}"],
12
+ "smartStep": true,
13
+ "console": "integratedTerminal"
14
+ }
15
+ ]
16
+ }
@@ -0,0 +1,10 @@
1
+ {
2
+ "emeraldwalk.runonsave": {
3
+ "commands": [
4
+ {
5
+ "match": ".*",
6
+ "cmd": "npx prettier-eslint ${file} --write"
7
+ }
8
+ ]
9
+ }
10
+ }
@@ -0,0 +1,3 @@
1
+ # <% app.name %>
2
+
3
+ App created with [AerogelJS](https://aerogel.js.org)
@@ -1,8 +1,16 @@
1
+ import install from '@aerogel/cypress/dist/plugin';
1
2
  import { defineConfig } from 'cypress';
2
3
 
3
4
  export default defineConfig({
4
5
  e2e: {
5
6
  baseUrl: 'http://localhost:5001',
6
7
  video: false,
8
+ retries: {
9
+ runMode: 3,
10
+ openMode: 0,
11
+ },
12
+ setupNodeEvents(on) {
13
+ install(on);
14
+ },
7
15
  },
8
16
  });
@@ -5,7 +5,7 @@
5
5
  <meta name="viewport" content="width=device-width, initial-scale=1.0" />
6
6
  <title><% app.name %></title>
7
7
  </head>
8
- <body class="h-full w-full">
8
+ <body class="h-full w-full text-base font-normal leading-tight text-gray-900 antialiased">
9
9
  <div id="app" class="h-full"></div>
10
10
  <script type="module" src="./src/main.ts"></script>
11
11
  </body>
@@ -8,6 +8,8 @@
8
8
  "cy:open": "cypress open --e2e --browser chromium",
9
9
  "cy:run": "cypress run",
10
10
  "cy:test": "start-server-and-test test:serve-app http-get://localhost:5001 cy:run",
11
+ "cy:test-snapshots": "docker run -it -u `id -u ${whoami}` -e CYPRESS_SNAPSHOTS=true -v ./:/app -w /app cypress/base:18.16.0 sh -c \"npx cypress install && npm run cy:test\"",
12
+ "cy:test-snapshots:ci": "docker run -e CYPRESS_SNAPSHOTS=true -v ./:/app -w /app cypress/base:18.16.0 sh -c \"npx cypress install && npm run cy:test\"",
11
13
  "dev": "vite",
12
14
  "lint": "noeldemartin-lint src",
13
15
  "test": "vitest --run",
@@ -15,30 +17,39 @@
15
17
  "test:serve-app": "vite --port 5001"
16
18
  },
17
19
  "dependencies": {
18
- "@aerogel/core": "next",
19
- "@aerogel/plugin-i18n": "next",
20
+ "@aerogel/core": "<% &dependencies.aerogelCore %>",
21
+ "@aerogel/plugin-i18n": "<% &dependencies.aerogelPluginI18n %>",
22
+ "@aerogel/plugin-soukai": "<% &dependencies.aerogelPluginSoukai %>",
20
23
  "@intlify/unplugin-vue-i18n": "^0.12.2",
24
+ "@noeldemartin/utils": "next",
21
25
  "@tailwindcss/forms": "^0.5.3",
22
26
  "@tailwindcss/typography": "^0.5.9",
23
- "soukai": "^0.5.1",
27
+ "soukai": "next",
24
28
  "tailwindcss": "^3.3.2",
25
29
  "vue": "^3.3.0",
26
- "vue-i18n": "9.3.0-beta.19",
27
- "vue-router": "^4.2.1"
30
+ "vue-i18n": "9.3.0-beta.19"
28
31
  },
29
32
  "devDependencies": {
30
- "@aerogel/cli": "next",
31
- "@aerogel/cypress": "next",
32
- "@aerogel/vite": "next",
33
- "@noeldemartin/utils": "0.4.0-next.ac00beaecf32bb02ed8e335225d7948d946d73bd",
33
+ "@aerogel/cli": "<% &dependencies.aerogelCli %>",
34
+ "@aerogel/cypress": "<% &dependencies.aerogelCypress %>",
35
+ "@aerogel/vite": "<% &dependencies.aerogelVite %>",
36
+ "@iconify/json": "^2.2.134",
37
+ "@noeldemartin/eslint-config-vue": "next",
38
+ "@noeldemartin/scripts": "next",
34
39
  "@total-typescript/ts-reset": "^0.4.2",
35
40
  "@types/node": "^20.3.1",
36
41
  "autoprefixer": "^10.4.14",
37
42
  "concurrently": "^8.2.0",
38
43
  "cypress": "^12.17.0",
44
+ "eslint": "^8.40.0",
45
+ "prettier": "^2.8.8",
46
+ "prettier-eslint-cli": "^7.1.0",
47
+ "prettier-plugin-tailwindcss": "^0.2.8",
39
48
  "start-server-and-test": "^2.0.0",
49
+ "unplugin-icons": "^0.16.3",
40
50
  "unplugin-vue-components": "^0.24.1",
41
51
  "vite": "^4.3.0",
42
- "vitest": "^0.33.0"
52
+ "vitest": "^0.33.0",
53
+ "vue-tsc": "^1.8.15"
43
54
  }
44
55
  }
@@ -0,0 +1,5 @@
1
+ /** @type {import('prettier').Config} */
2
+ module.exports = {
3
+ plugins: [require('prettier-plugin-tailwindcss')],
4
+ printWidth: 120,
5
+ };
@@ -1,7 +1,9 @@
1
1
  <template>
2
2
  <AGAppLayout>
3
3
  <main class="flex flex-grow flex-col items-center justify-center bg-blue-50">
4
- <h1 class="text-4xl font-semibold">{{ $t('home.title') }}</h1>
4
+ <h1 class="text-4xl font-semibold">
5
+ {{ $t('home.title') }}
6
+ </h1>
5
7
  <a href="https://aerogel.js.org" target="_blank" class="mt-2 underline opacity-75 hover:opacity-100">
6
8
  {{ $t('home.getStarted') }}
7
9
  </a>
@@ -1,9 +1,13 @@
1
1
  import i18n from '@aerogel/plugin-i18n';
2
+ import soukai from '@aerogel/plugin-soukai';
2
3
  import { bootstrapApplication } from '@aerogel/core';
3
4
 
4
5
  import './assets/styles.css';
5
6
  import App from './App.vue';
6
7
 
7
8
  bootstrapApplication(App, {
8
- plugins: [i18n({ messages: import.meta.glob('@/lang/*.yaml') })],
9
+ plugins: [
10
+ i18n({ messages: import.meta.glob('@/lang/*.yaml') }),
11
+ soukai({ models: import.meta.glob('@/models/*', { eager: true }) }),
12
+ ],
9
13
  });
@@ -1,3 +1,2 @@
1
1
  /// <reference types="vite/client" />
2
- /// <reference types="vue-router" />
3
2
  /// <reference types="vue-i18n" />
@@ -1,5 +1,5 @@
1
1
  /** @type {import('tailwindcss').Config} */
2
2
  module.exports = {
3
- content: ['./index.html', './src/**/*.{vue,ts}', '../core/src/**/*.{vue,ts}'],
3
+ content: ['./index.html', './src/**/*.{vue,ts}', '<% &contentPath %>'],
4
4
  plugins: [require('@tailwindcss/forms'), require('@tailwindcss/typography')],
5
5
  };
@@ -6,6 +6,7 @@
6
6
  "strict": true,
7
7
  "jsx": "preserve",
8
8
  "noUncheckedIndexedAccess": true,
9
+ "skipLibCheck": true,
9
10
  "resolveJsonModule": true,
10
11
  "esModuleInterop": true,
11
12
  "lib": ["esnext", "dom"],
@@ -1,16 +1,23 @@
1
1
  import Aerogel, { AerogelResolver } from '@aerogel/vite';
2
2
  import Components from 'unplugin-vue-components/vite';
3
3
  import I18n from '@intlify/unplugin-vue-i18n/vite';
4
+ import Icons from 'unplugin-icons/vite';
5
+ import IconsResolver from 'unplugin-icons/resolver';
6
+ import { defineConfig } from 'vitest/config';
4
7
  import { resolve } from 'path';
5
8
 
6
- export default {
9
+ export default defineConfig({
7
10
  plugins: [
8
- I18n({ include: resolve(__dirname, './src/lang/**/*.yaml') }),
9
11
  Aerogel(),
10
12
  Components({
11
- dirs: ['src/pages'],
12
13
  dts: false,
13
- resolvers: [AerogelResolver()],
14
+ resolvers: [AerogelResolver(), IconsResolver()],
15
+ }),
16
+ I18n({ include: resolve(__dirname, './src/lang/**/*.yaml') }),
17
+ Icons({
18
+ iconCustomizer(_, __, props) {
19
+ props['aria-hidden'] = 'true';
20
+ },
14
21
  }),
15
22
  ],
16
23
  resolve: {
@@ -18,4 +25,4 @@ export default {
18
25
  '@': resolve(__dirname, './src'),
19
26
  },
20
27
  },
21
- };
28
+ });
@@ -0,0 +1,8 @@
1
+ import { Service } from '@aerogel/core';
2
+ import { facade } from '@noeldemartin/utils';
3
+
4
+ export class <% service.name %>Service extends Service {
5
+
6
+ }
7
+
8
+ export default facade(new <% service.name %>Service());
@@ -1,4 +0,0 @@
1
- /** @type {import('@noeldemartin/scripts').Config} */
2
- module.exports = {
3
- external: ['fs', '@noeldemartin/utils', 'chalk', 'child_process', 'commander', 'mustache', 'path', 'readline'],
4
- };