@aerogel/cli 0.0.0-next.7e89f52eb37d9154f4879a5ccd058d27d476dada → 0.0.0-next.980a397d575dcb5ff8c5a0bff769d09f938ea03c

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 (53) 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 +10 -4
  6. package/src/commands/Command.ts +15 -7
  7. package/src/commands/create.test.ts +21 -4
  8. package/src/commands/create.ts +10 -7
  9. package/src/commands/generate-component.test.ts +59 -6
  10. package/src/commands/generate-component.ts +49 -14
  11. package/src/commands/generate-model.test.ts +11 -3
  12. package/src/commands/generate-model.ts +7 -8
  13. package/src/commands/generate-service.test.ts +10 -2
  14. package/src/commands/generate-service.ts +5 -6
  15. package/src/commands/install.test.ts +36 -5
  16. package/src/commands/install.ts +6 -5
  17. package/src/lib/Editor.ts +16 -9
  18. package/src/lib/Shell.mock.ts +1 -1
  19. package/src/lib/Template.ts +5 -1
  20. package/src/lib/utils/app.ts +1 -1
  21. package/src/lib/utils/paths.ts +1 -1
  22. package/src/plugins/Histoire.ts +105 -0
  23. package/src/plugins/Plugin.ts +57 -4
  24. package/src/plugins/Solid.ts +47 -34
  25. package/src/plugins/Soukai.ts +1 -1
  26. package/src/testing/stubs/ProgramStub.ts +35 -0
  27. package/src/testing/utils.ts +14 -0
  28. package/templates/app/.github/workflows/ci.yml +14 -2
  29. package/templates/app/README.md +3 -0
  30. package/templates/app/{cypress.config.ts → cypress/cypress.config.ts} +4 -0
  31. package/templates/app/index.html +3 -2
  32. package/templates/app/package.json +14 -2
  33. package/templates/app/src/App.vue +2 -2
  34. package/templates/app/src/assets/public/robots.txt +2 -0
  35. package/templates/app/src/main.ts +1 -1
  36. package/templates/app/tsconfig.json +1 -0
  37. package/templates/app/vite.config.ts +10 -4
  38. package/templates/component-button/[component.name].vue +32 -0
  39. package/templates/component-button-story/[component.name].story.vue +71 -0
  40. package/templates/component-input/[component.name].vue +16 -0
  41. package/templates/component-input-story/[component.name].story.vue +63 -0
  42. package/templates/histoire/histoire.config.ts +7 -0
  43. package/templates/histoire/patches/histoire+0.17.6.patch +13 -0
  44. package/templates/histoire/src/main.histoire.ts +8 -0
  45. package/templates/postcss-pseudo-classes/postcss.config.js +15 -0
  46. package/.eslintrc.js +0 -7
  47. package/noeldemartin.config.js +0 -14
  48. package/src/lib/utils/format.test.ts +0 -33
  49. package/src/lib/utils/format.ts +0 -38
  50. package/templates/app/.eslintrc.js +0 -3
  51. package/templates/app/prettier.config.js +0 -5
  52. /package/bin/{ag → gel} +0 -0
  53. /package/templates/app/src/assets/{styles.css → css/styles.css} +0 -0
@@ -0,0 +1,14 @@
1
+ import type { Constructor } from '@noeldemartin/utils';
2
+
3
+ import ProgramStub from '@/testing/stubs/ProgramStub';
4
+ import type Command from '@/commands/Command';
5
+
6
+ export type StubCommandRunner<T extends Constructor<Command>> = (...args: ConstructorParameters<T>) => Promise<void>;
7
+
8
+ export function stubCommandRunner<T extends Constructor<Command>>(commandClass: T): StubCommandRunner<T> {
9
+ const program = new ProgramStub();
10
+
11
+ (commandClass as unknown as typeof Command).define(program);
12
+
13
+ return (...args) => program.run(...args);
14
+ }
@@ -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,3 @@
1
+ # <% app.name %>
2
+
3
+ App created with [AerogelJS](https://aerogel.js.org)
@@ -5,6 +5,10 @@ export default defineConfig({
5
5
  e2e: {
6
6
  baseUrl: 'http://localhost:5001',
7
7
  video: false,
8
+ retries: {
9
+ runMode: 3,
10
+ openMode: 0,
11
+ },
8
12
  setupNodeEvents(on) {
9
13
  install(on);
10
14
  },
@@ -3,10 +3,11 @@
3
3
  <head>
4
4
  <meta charset="UTF-8" />
5
5
  <meta name="viewport" content="width=device-width, initial-scale=1.0" />
6
- <title><% app.name %></title>
6
+ <title>{{ app.name }}</title>
7
+ {{ socialMeta() }}
7
8
  </head>
8
9
  <body class="h-full w-full text-base font-normal leading-tight text-gray-900 antialiased">
9
- <div id="app" class="h-full"></div>
10
+ <div id="app" class="loading h-full"></div>
10
11
  <script type="module" src="./src/main.ts"></script>
11
12
  </body>
12
13
  </html>
@@ -5,8 +5,8 @@
5
5
  "scripts": {
6
6
  "build": "vite build",
7
7
  "cy:dev": "concurrently --kill-others \"npm run test:serve-app\" \"npm run cy:open\"",
8
- "cy:open": "cypress open --e2e --browser chromium",
9
- "cy:run": "cypress run",
8
+ "cy:open": "cypress open --config-file ./cypress/cypress.config.ts --e2e --browser chromium",
9
+ "cy:run": "cypress run --config-file ./cypress/cypress.config.ts",
10
10
  "cy:test": "start-server-and-test test:serve-app http-get://localhost:5001 cy:run",
11
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
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\"",
@@ -33,6 +33,7 @@
33
33
  "@aerogel/cli": "<% &dependencies.aerogelCli %>",
34
34
  "@aerogel/cypress": "<% &dependencies.aerogelCypress %>",
35
35
  "@aerogel/vite": "<% &dependencies.aerogelVite %>",
36
+ "@iconify/json": "^2.2.134",
36
37
  "@noeldemartin/eslint-config-vue": "next",
37
38
  "@noeldemartin/scripts": "next",
38
39
  "@total-typescript/ts-reset": "^0.4.2",
@@ -50,5 +51,16 @@
50
51
  "vite": "^4.3.0",
51
52
  "vitest": "^0.33.0",
52
53
  "vue-tsc": "^1.8.15"
54
+ },
55
+ "eslintConfig": {
56
+ "extends": [
57
+ "@noeldemartin/eslint-config-vue"
58
+ ]
59
+ },
60
+ "prettier": {
61
+ "plugins": [
62
+ "prettier-plugin-tailwindcss"
63
+ ],
64
+ "printWidth": 120
53
65
  }
54
66
  }
@@ -1,6 +1,6 @@
1
1
  <template>
2
- <AGAppLayout>
3
- <main class="flex flex-grow flex-col items-center justify-center bg-blue-50">
2
+ <AGAppLayout class="bg-blue-50">
3
+ <main class="flex flex-grow flex-col items-center justify-center">
4
4
  <h1 class="text-4xl font-semibold">
5
5
  {{ $t('home.title') }}
6
6
  </h1>
@@ -0,0 +1,2 @@
1
+ User-agent: *
2
+ Disallow:
@@ -2,7 +2,7 @@ import i18n from '@aerogel/plugin-i18n';
2
2
  import soukai from '@aerogel/plugin-soukai';
3
3
  import { bootstrapApplication } from '@aerogel/core';
4
4
 
5
- import './assets/styles.css';
5
+ import './assets/css/styles.css';
6
6
  import App from './App.vue';
7
7
 
8
8
  bootstrapApplication(App, {
@@ -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"],
@@ -3,21 +3,27 @@ import Components from 'unplugin-vue-components/vite';
3
3
  import I18n from '@intlify/unplugin-vue-i18n/vite';
4
4
  import Icons from 'unplugin-icons/vite';
5
5
  import IconsResolver from 'unplugin-icons/resolver';
6
+ import { defineConfig } from 'vitest/config';
6
7
  import { resolve } from 'path';
7
8
 
8
- export default {
9
+ export default defineConfig({
10
+ publicDir: resolve(__dirname, './src/assets/public/'),
9
11
  plugins: [
10
- Aerogel(),
12
+ Aerogel({ name: '<% app.name %>' }),
11
13
  Components({
12
14
  dts: false,
13
15
  resolvers: [AerogelResolver(), IconsResolver()],
14
16
  }),
15
17
  I18n({ include: resolve(__dirname, './src/lang/**/*.yaml') }),
16
- Icons(),
18
+ Icons({
19
+ iconCustomizer(_, __, props) {
20
+ props['aria-hidden'] = 'true';
21
+ },
22
+ }),
17
23
  ],
18
24
  resolve: {
19
25
  alias: {
20
26
  '@': resolve(__dirname, './src'),
21
27
  },
22
28
  },
23
- };
29
+ });
@@ -0,0 +1,32 @@
1
+ <template>
2
+ <AGHeadlessButton :class="colorClasses">
3
+ <slot />
4
+ </AGHeadlessButton>
5
+ </template>
6
+
7
+ <script setup lang="ts">
8
+ import { Colors, enumProp } from '@aerogel/core';
9
+ import { computed } from 'vue';
10
+
11
+ const props = defineProps({
12
+ color: enumProp(Colors, Colors.Primary),
13
+ });
14
+
15
+ const colorClasses = computed(() => {
16
+ switch (props.color) {
17
+ case Colors.Secondary:
18
+ // Add your custom color classes here.
19
+ return '';
20
+ case Colors.Clear:
21
+ // Add your custom color classes here.
22
+ return '';
23
+ case Colors.Danger:
24
+ // Add your custom color classes here.
25
+ return '';
26
+ case Colors.Primary:
27
+ default:
28
+ // Add your custom color classes here.
29
+ return '';
30
+ }
31
+ });
32
+ </script>
@@ -0,0 +1,71 @@
1
+ <template>
2
+ <Story :layout="{ type: 'grid' }">
3
+ <Variant title="Playground">
4
+ <<% component.name %> :color="color">
5
+ {{ content }}
6
+ </<% component.name %>>
7
+
8
+ <template #controls>
9
+ <HstText v-model="content" title="Content" />
10
+ <HstSelect v-model="color" title="Color" :options="colorOptions" />
11
+ </template>
12
+ </Variant>
13
+
14
+ <Variant title="Default">
15
+ <<% component.name %>>
16
+ Click me!
17
+ </<% component.name %>>
18
+ </Variant>
19
+
20
+ <Variant title="Hover">
21
+ <<% component.name %> class=":hover">
22
+ Click me!
23
+ </<% component.name %>>
24
+ </Variant>
25
+
26
+ <Variant title="Focus">
27
+ <<% component.name %> class=":focus :focus-visible">
28
+ Click me!
29
+ </<% component.name %>>
30
+ </Variant>
31
+
32
+ <Variant title="Colors" :layout="{ width: '300px' }">
33
+ <div class="flex items-center gap-2">
34
+ <<% component.name %> color="primary">
35
+ Primary
36
+ </<% component.name %>>
37
+ <<% component.name %> color="secondary">
38
+ Secondary
39
+ </<% component.name %>>
40
+ <<% component.name %> color="danger">
41
+ Danger
42
+ </<% component.name %>>
43
+ <<% component.name %> color="clear">
44
+ Clear
45
+ </<% component.name %>>
46
+ </div>
47
+ </Variant>
48
+ </Story>
49
+ </template>
50
+
51
+ <script setup lang="ts">
52
+ import { Colors } from '@aerogel/core';
53
+ import { invert } from '@noeldemartin/utils';
54
+ import { ref } from 'vue';
55
+ import type { Color } from '@aerogel/core';
56
+
57
+ const content = ref('Click me!');
58
+ const color = ref<Color>(Colors.Primary);
59
+ const colorOptions = invert(Colors);
60
+ </script>
61
+
62
+ <style>
63
+ .story-<% component.slug %> {
64
+ grid-template-columns: repeat(3, 200px) !important;
65
+ }
66
+
67
+ .story-<% component.slug %> .variant-playground,
68
+ .story-<% component.slug %> .variant-colors{
69
+ grid-column: 1 / -1;
70
+ }
71
+ </style>
@@ -0,0 +1,16 @@
1
+ <template>
2
+ <AGHeadlessInput v-bind="props">
3
+ <AGHeadlessInputLabel />
4
+ <AGHeadlessInputInput v-bind="attrs" />
5
+ <AGHeadlessInputError />
6
+ </AGHeadlessInput>
7
+ </template>
8
+
9
+ <script setup lang="ts">
10
+ import { useInputAttrs, useInputProps } from '@aerogel/core';
11
+
12
+ defineOptions({ inheritAttrs: false });
13
+
14
+ const props = defineProps(useInputProps());
15
+ const [attrs] = useInputAttrs();
16
+ </script>
@@ -0,0 +1,63 @@
1
+ <template>
2
+ <Story :layout="{ type: 'grid' }">
3
+ <Variant title="Playground">
4
+ <AGForm :form="form">
5
+ <<% component.name %> name="food" :label="label" :placeholder="placeholder" />
6
+ </AGForm>
7
+
8
+ <template #controls>
9
+ <HstText v-model="label" title="Label" />
10
+ <HstText v-model="placeholder" title="Placeholder" />
11
+ <HstCheckbox v-model="hasErrors" title="Errors" />
12
+ </template>
13
+ </Variant>
14
+
15
+ <Variant title="Default">
16
+ <<% component.name %> label="What's the best food?" placeholder="Ramen" />
17
+ </Variant>
18
+
19
+ <Variant title="Hover">
20
+ <<% component.name %> label="What's the best food?" placeholder="Ramen" input-class=":hover" />
21
+ </Variant>
22
+
23
+ <Variant title="Focus">
24
+ <<% component.name %> label="What's the best food?" placeholder="Ramen" input-class=":focus :focus-visible" />
25
+ </Variant>
26
+
27
+ <Variant title="Error">
28
+ <AGForm :form="errorForm">
29
+ <<% component.name %>
30
+ name="food"
31
+ label="What's the best food?"
32
+ placeholder="Ramen"
33
+ class=":focus :focus-visible"
34
+ />
35
+ </AGForm>
36
+ </Variant>
37
+ </Story>
38
+ </template>
39
+
40
+ <script setup lang="ts">
41
+ import { requiredStringInput, useForm } from '@aerogel/core';
42
+ import { ref, watchEffect } from 'vue';
43
+
44
+ const form = useForm({ food: requiredStringInput() });
45
+ const errorForm = useForm({ food: requiredStringInput() });
46
+ const label = ref('What\'s the best food?');
47
+ const placeholder = ref('Ramen');
48
+ const hasErrors = ref(false);
49
+
50
+ errorForm.submit();
51
+
52
+ watchEffect(() => (hasErrors.value ? form.submit() : form.reset()));
53
+ </script>
54
+
55
+ <style>
56
+ .story-<% component.slug %> {
57
+ grid-template-columns: repeat(2, 300px) !important;
58
+ }
59
+
60
+ .story-<% component.slug %> .variant-playground {
61
+ grid-column: 1 / -1;
62
+ }
63
+ </style>
@@ -0,0 +1,7 @@
1
+ import HstAerogel from '@aerogel/histoire/dist/plugin';
2
+ import { defineConfig } from 'histoire';
3
+
4
+ export default defineConfig({
5
+ setupFile: '/src/main.histoire.ts',
6
+ plugins: [HstAerogel()],
7
+ });
@@ -0,0 +1,13 @@
1
+ diff --git a/node_modules/histoire/dist/node/collect/index.js b/node_modules/histoire/dist/node/collect/index.js
2
+ index 8ffd507..37be43e 100644
3
+ --- a/node_modules/histoire/dist/node/collect/index.js
4
+ +++ b/node_modules/histoire/dist/node/collect/index.js
5
+ @@ -22,7 +22,7 @@ export function useCollectStories(options, ctx) {
6
+ /vite\w*\/dist\/client\/(client|env).mjs/,
7
+ ...ctx.config.viteNodeInlineDeps ?? [],
8
+ ],
9
+ - fallbackCJS: true,
10
+ + fallbackCJS: false,
11
+ },
12
+ transformMode: ctx.config.viteNodeTransformMode,
13
+ });
@@ -0,0 +1,8 @@
1
+ import '@aerogel/histoire/dist/styles.css';
2
+ import { defineSetupAerogel } from '@aerogel/histoire';
3
+
4
+ import './assets/css/styles.css';
5
+
6
+ export const setupVue3 = defineSetupAerogel({
7
+ messages: import.meta.glob('@/lang/*.yaml'),
8
+ });
@@ -0,0 +1,15 @@
1
+ const plugins = {
2
+ tailwindcss: {},
3
+ autoprefixer: {},
4
+ };
5
+
6
+ if (process.env.NODE_ENV === 'development') {
7
+ plugins['postcss-pseudo-classes'] = {
8
+ blacklist: [],
9
+ restrictTo: ['hover', 'focus-visible', 'focus'],
10
+ allCombinations: true,
11
+ preserveBeforeAfter: false,
12
+ };
13
+ }
14
+
15
+ module.exports = { plugins };
package/.eslintrc.js DELETED
@@ -1,7 +0,0 @@
1
- module.exports = {
2
- env: {
3
- browser: true,
4
- es2021: true,
5
- },
6
- extends: ['@noeldemartin/eslint-config-typescript'],
7
- };
@@ -1,14 +0,0 @@
1
- /** @type {import('@noeldemartin/scripts').Config} */
2
- module.exports = {
3
- external: [
4
- '@noeldemartin/utils',
5
- 'chalk',
6
- 'child_process',
7
- 'commander',
8
- 'fs',
9
- 'mustache',
10
- 'path',
11
- 'readline',
12
- 'ts-morph',
13
- ],
14
- };
@@ -1,33 +0,0 @@
1
- import { describe, expect, it } from 'vitest';
2
-
3
- import { formatCodeBlock } from './format';
4
-
5
- describe('Format 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
- });
@@ -1,38 +0,0 @@
1
- export interface FormatCodeBlockOptions {
2
- indent?: number;
3
- }
4
-
5
- export function formatCodeBlock(code: string, options: FormatCodeBlockOptions = {}): string {
6
- const lines = code.split('\n');
7
- const indent = options.indent ?? 0;
8
- let originalIndent = 0;
9
- let formatted = '';
10
-
11
- for (const line of lines) {
12
- const trimmedLine = line.trim();
13
- const isEmptyLine = trimmedLine.length === 0;
14
-
15
- if (formatted.length === 0) {
16
- if (isEmptyLine) {
17
- continue;
18
- }
19
-
20
- originalIndent = line.indexOf(trimmedLine[0] ?? '');
21
- formatted += `${' '.repeat(indent)}${trimmedLine}\n`;
22
-
23
- continue;
24
- }
25
-
26
- if (isEmptyLine) {
27
- formatted += '\n';
28
-
29
- continue;
30
- }
31
-
32
- const lineIndent = line.indexOf(trimmedLine[0] ?? '');
33
-
34
- formatted += `${' '.repeat(indent + lineIndent - originalIndent)}${trimmedLine}\n`;
35
- }
36
-
37
- return formatted.trimEnd();
38
- }
@@ -1,3 +0,0 @@
1
- module.exports = {
2
- extends: ['@noeldemartin/eslint-config-vue'],
3
- };
@@ -1,5 +0,0 @@
1
- /** @type {import('prettier').Config} */
2
- module.exports = {
3
- plugins: [require('prettier-plugin-tailwindcss')],
4
- printWidth: 120,
5
- };
/package/bin/{ag → gel} RENAMED
File without changes