create-outsystems-astro 0.4.2 → 0.6.0
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/README.md +5 -0
- package/bin/cli.js +6 -1
- package/package.json +1 -1
- package/template/.prettierignore +4 -1
- package/template/.prettierrc +4 -0
- package/template/AGENTS.md +104 -15
- package/template/astro.config.mjs +2 -0
- package/template/bun.lock +621 -656
- package/template/deno.json +1 -5
- package/template/deno.lock +1303 -977
- package/template/eslint.config.mjs +19 -0
- package/template/output.ts +14 -2
- package/template/package-lock.json +3949 -4042
- package/template/package.json +62 -58
- package/template/pnpm-lock.yaml +2431 -1927
- package/template/pnpm-workspace.yaml +6 -0
- package/template/src/framework/angular/Counter.component.ts +25 -13
- package/template/src/framework/react/Counter.tsx +41 -9
- package/template/src/framework/svelte/Counter.svelte +77 -0
- package/template/src/framework/vue/Counter.vue +49 -14
- package/template/src/pages/angular/angular-counter.astro +30 -10
- package/template/src/pages/react/react-counter.astro +58 -16
- package/template/src/pages/svelte/svelte-counter.astro +63 -0
- package/template/src/pages/vue/vue-counter.astro +61 -15
- package/template/src/stores/.gitkeep +0 -0
- package/template/src/styles/index.css +65 -0
- package/template/svelte.config.js +5 -0
- package/template/test/e2e/react/react-counter.spec.ts +12 -2
- package/template/test/e2e/svelte/svelte-counter.spec.ts +42 -0
- package/template/test/e2e/vue/vue-counter.spec.ts +12 -2
- package/template/test/integration/angular/Counter.component.spec.ts +1 -1
- package/template/test/integration/react/Counter.test.tsx +35 -10
- package/template/test/integration/svelte/Counter.test.ts +81 -0
- package/template/test/integration/svelte/SlotCounter.wrapper.svelte +27 -0
- package/template/test/integration/vue/Counter.test.ts +42 -4
- package/template/vitest.config.ts +17 -2
- package/template/yarn.lock +3656 -2059
- /package/template/patches/{@analogjs+astro-angular+2.2.2.patch → @analogjs+astro-angular+2.3.0.patch} +0 -0
- /package/template/patches/{@angular+build+21.1.0.patch → @angular+build+21.2.0.patch} +0 -0
package/README.md
CHANGED
|
@@ -93,6 +93,7 @@ All commands are run from the root of the project, from a terminal:
|
|
|
93
93
|
| `npm run preview` | Preview build locally, before creating output |
|
|
94
94
|
| `npm run astro ...` | Run CLI commands like `astro add`, `astro check` |
|
|
95
95
|
| `npm run astro -- --help` | Get help using the Astro CLI |
|
|
96
|
+
| `npm run audit:npm` | Run audit of modules |
|
|
96
97
|
|
|
97
98
|
### Yarn
|
|
98
99
|
|
|
@@ -105,6 +106,7 @@ All commands are run from the root of the project, from a terminal:
|
|
|
105
106
|
| `yarn run preview` | Preview build locally, before creating output |
|
|
106
107
|
| `yarn run astro ...` | Run CLI commands like `astro add`, `astro check` |
|
|
107
108
|
| `yarn run astro -- --help` | Get help using the Astro CLI |
|
|
109
|
+
| `yarn run audit:yarn` | Run audit of modules |
|
|
108
110
|
|
|
109
111
|
### pnpm
|
|
110
112
|
|
|
@@ -117,6 +119,7 @@ All commands are run from the root of the project, from a terminal:
|
|
|
117
119
|
| `pnpm run preview` | Preview build locally, before creating output |
|
|
118
120
|
| `pnpm run astro ...` | Run CLI commands like `astro add`, `astro check` |
|
|
119
121
|
| `pnpm run astro -- --help` | Get help using the Astro CLI |
|
|
122
|
+
| `pnpm run audit:pnpm` | Run audit of modules |
|
|
120
123
|
|
|
121
124
|
### Bun
|
|
122
125
|
|
|
@@ -129,6 +132,7 @@ All commands are run from the root of the project, from a terminal:
|
|
|
129
132
|
| `bun run preview` | Preview build locally, before creating output |
|
|
130
133
|
| `bun run astro ...` | Run CLI commands like `astro add`, `astro check` |
|
|
131
134
|
| `bun run astro -- --help` | Get help using the Astro CLI |
|
|
135
|
+
| `bun run audit:bun` | Run audit of modules |
|
|
132
136
|
|
|
133
137
|
### Deno
|
|
134
138
|
|
|
@@ -141,6 +145,7 @@ All commands are run from the root of the project, from a terminal:
|
|
|
141
145
|
| `deno run preview` | Preview build locally, before creating output |
|
|
142
146
|
| `deno run astro ...` | Run CLI commands like `astro add`, `astro check` |
|
|
143
147
|
| `deno run astro -- --help` | Get help using the Astro CLI |
|
|
148
|
+
| `deno run audit:deno` | Run audit of modules |
|
|
144
149
|
|
|
145
150
|
## Getting Started
|
|
146
151
|
Delete the demo application under the ```src``` folder and being to build your own application.
|
package/bin/cli.js
CHANGED
|
@@ -17,13 +17,14 @@ const __dirname = path.dirname(__filename);
|
|
|
17
17
|
const FRAMEWORKS = [
|
|
18
18
|
{ title: "Angular", value: "angular" },
|
|
19
19
|
{ title: "React", value: "react" },
|
|
20
|
+
{ title: "Svelte", value: "svelte" },
|
|
20
21
|
{ title: "Vue", value: "vue" }
|
|
21
22
|
];
|
|
22
23
|
|
|
23
24
|
const LOCKFILES = {
|
|
24
25
|
npm: ["package-lock.json"],
|
|
25
26
|
yarn: ["yarn.lock"],
|
|
26
|
-
pnpm: ["pnpm-lock.yaml"],
|
|
27
|
+
pnpm: ["pnpm-lock.yaml", "pnpm-workspace.yaml"],
|
|
27
28
|
bun: ["bun.lock"],
|
|
28
29
|
deno: ["deno.lock", "deno.json"]
|
|
29
30
|
};
|
|
@@ -156,6 +157,10 @@ function updateAstroConfig(projectDir, selectedFrameworks) {
|
|
|
156
157
|
import: /import\s+react\s+from\s+['"]@astrojs\/react['"];\s*\n?/,
|
|
157
158
|
integration: /react\(\)\s*,?\s*/
|
|
158
159
|
},
|
|
160
|
+
svelte: {
|
|
161
|
+
import: /import\s+svelte\s+from\s+['"]@astrojs\/svelte['"];\s*\n?/,
|
|
162
|
+
integration: /svelte\(\)\s*,?\s*/
|
|
163
|
+
},
|
|
159
164
|
vue: {
|
|
160
165
|
import: /import\s+vue\s+from\s+['"]@astrojs\/vue['"];\s*\n?/,
|
|
161
166
|
integration: /vue\(\)\s*,?\s*/
|
package/package.json
CHANGED
package/template/.prettierignore
CHANGED
package/template/.prettierrc
CHANGED
package/template/AGENTS.md
CHANGED
|
@@ -24,27 +24,41 @@
|
|
|
24
24
|
- The project can intialized from the Create OutSystems Astro package (https://www.npmjs.com/package/create-outsystems-astro).
|
|
25
25
|
- In this document, for any reference to running package manager script, the `PM` attribute should be replaced with whatever package manager the user is using.
|
|
26
26
|
|
|
27
|
+
In OutSystems 11, the Islands library is available at https://www.outsystems.com/forge/component-overview/22857/islands-o11.
|
|
28
|
+
|
|
29
|
+
In OutSystems Developer Cloud, the Islands library is available at https://www.outsystems.com/forge/component-overview/22960/islands-odc.
|
|
30
|
+
|
|
27
31
|
### Pages
|
|
28
32
|
|
|
29
33
|
- The files in src/pages/\*.astro are used as a starting point and holds the components for generation. They can be tested by running `npm run dev`. That will show what the component looks like as rendered. The sample example pages are broken out by framework name (src/pages/react, src/pages/vue, etc). This page will house the component(s) entry points.
|
|
30
|
-
- When importing a component, the component must have the attribute of the client:only= + the framework name
|
|
31
|
-
-
|
|
32
|
-
-
|
|
33
|
-
-
|
|
34
|
+
- When importing a component, the component must have the attribute of the client:only= + the framework name.\
|
|
35
|
+
- Angular: `client:visible`
|
|
36
|
+
- React: `client:only="react"`
|
|
37
|
+
- Svelte: `client:only="svelte"`
|
|
38
|
+
- Vue: `client:only="vue"`
|
|
34
39
|
|
|
35
40
|
### Components
|
|
36
41
|
|
|
37
|
-
- The components live in the folder framework/
|
|
42
|
+
- The components live in the folder framework/{NAME}/:
|
|
43
|
+
- Angular: src/framework/angular
|
|
44
|
+
- React: src/framework/react
|
|
45
|
+
- Svelte: src/framework/svelte
|
|
46
|
+
- Vue: src/framework/vue
|
|
47
|
+
The framework folder should stay in place as the components will be rendered from there. The Angular components will only be transformed by Astro if they are in the framework/angular folder.
|
|
38
48
|
|
|
39
49
|
### Parameters
|
|
40
50
|
|
|
41
51
|
- Parameters are assigned as attributes on the component. Each framework will then handle them as incoming parameters.
|
|
42
|
-
- OutSystems will pass in parameters already prepared for the
|
|
52
|
+
- OutSystems will pass in parameters already prepared for the astro-island. It already has copied the Astro method of serialization in https://github.com/withastro/astro/blob/main/packages/astro/src/runtime/server/serialize.ts.
|
|
43
53
|
|
|
44
54
|
#### Slots
|
|
45
55
|
|
|
46
56
|
Astro slots can be sent in. A slot can be either the default one or the named one. Each framework handles slots differently. Slots can only be HTML elements and cannot be components of a framework.
|
|
47
57
|
|
|
58
|
+
##### Angular
|
|
59
|
+
|
|
60
|
+
Angular does not support the use of slots. Any use of slots with Angular should be discouraged.
|
|
61
|
+
|
|
48
62
|
##### React
|
|
49
63
|
|
|
50
64
|
- In React, slots are handled as props. The default slot is the `children` prop. A named slot will have the name of its slot as the parameter. For example, a slot with the following:
|
|
@@ -63,10 +77,10 @@ import CounterComponent from '../../framework/react/Counter';
|
|
|
63
77
|
---
|
|
64
78
|
<CounterComponent client:only="react">
|
|
65
79
|
<div slot="header">
|
|
66
|
-
Counter
|
|
80
|
+
Counter Component
|
|
67
81
|
</div>
|
|
68
82
|
<div style="text-align: center;">
|
|
69
|
-
<p>
|
|
83
|
+
<p>This is content passed into the component.</p>
|
|
70
84
|
</div>
|
|
71
85
|
</CounterComponent>
|
|
72
86
|
```
|
|
@@ -93,6 +107,31 @@ export default function Counter({
|
|
|
93
107
|
}
|
|
94
108
|
```
|
|
95
109
|
|
|
110
|
+
##### Svelte
|
|
111
|
+
|
|
112
|
+
- In Svelte, slots are handled as by using the <slot /> tag. The default slot is the is just <slot />. A named slot will have the name of its slot as an attribute such as <slot name="header" />. Placement of the slot will determine where the slot will render.
|
|
113
|
+
|
|
114
|
+
```js
|
|
115
|
+
---
|
|
116
|
+
import CounterComponent from "../../framework/svelte/Counter.svelte";
|
|
117
|
+
---
|
|
118
|
+
<CounterComponent client:only="svelte">
|
|
119
|
+
<div class="counter-title" slot="header">Counter Component</div>
|
|
120
|
+
<div style="text-align: center;">
|
|
121
|
+
<p><strong>This is content passed into the component.</strong></p>
|
|
122
|
+
</div>
|
|
123
|
+
</CounterComponent>
|
|
124
|
+
```
|
|
125
|
+
|
|
126
|
+
the slots can be used as:
|
|
127
|
+
|
|
128
|
+
```svelte
|
|
129
|
+
<slot name="header" />
|
|
130
|
+
<div>
|
|
131
|
+
<slot />
|
|
132
|
+
</div>
|
|
133
|
+
```
|
|
134
|
+
|
|
96
135
|
##### Vue
|
|
97
136
|
|
|
98
137
|
- In Vue, slots are handled as by using the <slot /> tag. The default slot is the is just <slot />. A named slot will have the name of its slot as an attribute such as <slot name="header" />. Placement of the slot will determine where the slot will render.
|
|
@@ -103,10 +142,10 @@ import CounterComponent from '../../framework/react/Counter';
|
|
|
103
142
|
---
|
|
104
143
|
<CounterComponent client:only="vue">
|
|
105
144
|
<div slot="header">
|
|
106
|
-
Counter
|
|
145
|
+
Counter Component
|
|
107
146
|
</div>
|
|
108
147
|
<div style="text-align: center;">
|
|
109
|
-
<p>
|
|
148
|
+
<p>This is content passed into the component.</p>
|
|
110
149
|
</div>
|
|
111
150
|
</CounterComponent>
|
|
112
151
|
```
|
|
@@ -122,16 +161,66 @@ the slots can be used as:
|
|
|
122
161
|
</template>
|
|
123
162
|
```
|
|
124
163
|
|
|
125
|
-
|
|
164
|
+
### Nano Stores
|
|
126
165
|
|
|
127
|
-
|
|
166
|
+
The Nano Stores library - https://github.com/nanostores/nanostores - is supported for both sharing state between different Islands or from OutSystems to an Island. This could be used in place of a parameter, but parameters should be the default method.
|
|
167
|
+
|
|
168
|
+
The current supported OutSystems Nano Stores module only suports Atoms and Maps. It can either subscribe to an Atom or Map. It can also listen to Keys of a Map.
|
|
169
|
+
|
|
170
|
+
The OutSystems 11 library is called Lightweight State Manager - https://www.outsystems.com/forge/component-overview/23528/lightweight-state-manager-o11 is available in the O11 Forge.
|
|
171
|
+
|
|
172
|
+
The OutSystems Developer Cloud library is called Lightweight State Manager and is available in the ODC Forge.
|
|
173
|
+
|
|
174
|
+
Nano Stores are currently supported for only React - https://github.com/nanostores/react and Vue - https://github.com/nanostores/vue. The Angular 21 library does not yet support them.
|
|
175
|
+
|
|
176
|
+
In OutSystems, the store will be on the Window object. The Islands component will then have to access it from there.
|
|
177
|
+
|
|
178
|
+
#### React
|
|
179
|
+
|
|
180
|
+
```js
|
|
181
|
+
import { useStore } from "@nanostores/react";
|
|
182
|
+
import { useState } from "react";
|
|
183
|
+
|
|
184
|
+
export default function Counter({}) {
|
|
185
|
+
const nanoStoreValue = useStore(window.Stores["MyGreatStore"]);
|
|
186
|
+
|
|
187
|
+
return (
|
|
188
|
+
<>
|
|
189
|
+
<div>{nanoStoreValue}</div>
|
|
190
|
+
</>
|
|
191
|
+
);
|
|
192
|
+
}
|
|
193
|
+
```
|
|
194
|
+
|
|
195
|
+
#### Svelte
|
|
196
|
+
|
|
197
|
+
```svelte
|
|
198
|
+
<script lang="ts">
|
|
199
|
+
const nanoStoreValue = (window as any).Stores["svelteStore"];
|
|
200
|
+
</script>
|
|
201
|
+
|
|
202
|
+
<div>{$nanoStoreValue}</div>
|
|
203
|
+
```
|
|
204
|
+
|
|
205
|
+
#### Vue
|
|
206
|
+
|
|
207
|
+
```vue
|
|
208
|
+
<script setup lang="ts">
|
|
209
|
+
import { useStore } from "@nanostores/vue";
|
|
210
|
+
const nanoStoreValue = useStore(window.Stores["MyGreatStore"]);
|
|
211
|
+
</script>
|
|
212
|
+
|
|
213
|
+
<template>
|
|
214
|
+
<div>{{ nanoStoreValue }}</div>
|
|
215
|
+
</template>
|
|
216
|
+
```
|
|
128
217
|
|
|
129
218
|
### Testing
|
|
130
219
|
|
|
131
220
|
- There is a preset set of testing tools, but can be changed after generation.
|
|
132
221
|
- The unit testing library setup is Vitest. The unit tests are located in `test/unit` folder.
|
|
133
|
-
- The integration testing library is Testing Library with an equivalent library per framework. Each framework is in its own folder in `test/integration/
|
|
134
|
-
- The end-to-end testing library is Playwright. Each framework is in its own folder in `test/e2e/
|
|
222
|
+
- The integration testing library is Testing Library with an equivalent library per framework. Each framework is in its own folder in `test/integration/{FRAMEWORK}`.
|
|
223
|
+
- The end-to-end testing library is Playwright. Each framework is in its own folder in `test/e2e/{FRAMEWORK}`.
|
|
135
224
|
|
|
136
225
|
### Linting and formatting
|
|
137
226
|
|
|
@@ -143,7 +232,7 @@ Angular does not support the use of slots. Any use of slots with Angular should
|
|
|
143
232
|
|
|
144
233
|
### Handlers
|
|
145
234
|
|
|
146
|
-
- Incoming functions from OutSystems cannot be passed as function handlers. The way that OutSystems will invoke them is by binding the function with the name to the `
|
|
235
|
+
- Incoming functions from OutSystems cannot be passed as function handlers. The way that OutSystems will invoke them is by binding the function with the name to the `window` object of the page. Then it will pass in that name as a parameter. For example, if you need a function handler of `ShowMessage`, it will need to be called as `window[ShowMessage]`.
|
|
147
236
|
- Passing in basic text, number and boolean should be fine to the handler. Any array or object must be JSON stringified prior to being passed into the handler.
|
|
148
237
|
|
|
149
238
|
## Generating output
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
// @ts-check
|
|
2
2
|
import angular from "@analogjs/astro-angular";
|
|
3
3
|
import react from "@astrojs/react";
|
|
4
|
+
import svelte from "@astrojs/svelte";
|
|
4
5
|
import vue from "@astrojs/vue";
|
|
5
6
|
import { defineConfig } from "astro/config";
|
|
6
7
|
|
|
@@ -19,6 +20,7 @@ export default defineConfig({
|
|
|
19
20
|
}),
|
|
20
21
|
react(),
|
|
21
22
|
vue(),
|
|
23
|
+
svelte(),
|
|
22
24
|
],
|
|
23
25
|
server: {
|
|
24
26
|
host: true,
|