@revenexx/integrations-node-devkit 0.2.1 → 0.3.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 +35 -13
- package/dist/{chunk-UBYGZFB7.js → chunk-PS3HCKE7.js} +263 -68
- package/dist/chunk-PS3HCKE7.js.map +1 -0
- package/dist/cli.cjs +426 -545
- package/dist/cli.cjs.map +1 -1
- package/dist/cli.js +140 -452
- package/dist/cli.js.map +1 -1
- package/dist/index.cjs +258 -68
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +80 -8
- package/dist/index.d.ts +80 -8
- package/dist/index.js +1 -1
- package/package.json +7 -4
- package/preview-host/app.vue +22 -0
- package/preview-host/assets/css/main.css +22 -0
- package/preview-host/composables/devkit-console-stubs.ts +52 -0
- package/preview-host/middleware/hide-workflows.global.ts +13 -0
- package/preview-host/nuxt.config.ts +38 -0
- package/preview-host/package.json +37 -0
- package/preview-host/pages/index.vue +63 -0
- package/preview-host/pages/nodes.vue +208 -0
- package/dist/chunk-UBYGZFB7.js.map +0 -1
package/dist/cli.js
CHANGED
|
@@ -4,464 +4,122 @@ import {
|
|
|
4
4
|
DevStore,
|
|
5
5
|
applySeeds,
|
|
6
6
|
createRequestListener,
|
|
7
|
+
isReloadableSource,
|
|
7
8
|
loadEnvFile,
|
|
8
9
|
loadPackageFromEntry,
|
|
9
10
|
loadSeedsFromDir,
|
|
10
11
|
loadState,
|
|
11
12
|
saveState
|
|
12
|
-
} from "./chunk-
|
|
13
|
+
} from "./chunk-PS3HCKE7.js";
|
|
13
14
|
|
|
14
15
|
// src/cli.ts
|
|
15
|
-
import { existsSync as existsSync2, readdirSync, readFileSync, watch } from "fs";
|
|
16
|
+
import { existsSync as existsSync2, readdirSync, readFileSync as readFileSync2, watch } from "fs";
|
|
16
17
|
import { createServer } from "http";
|
|
17
18
|
import { createRequire } from "module";
|
|
18
19
|
import { extname, join as join2, resolve as resolve2 } from "path";
|
|
19
|
-
import { fileURLToPath } from "url";
|
|
20
|
-
|
|
21
|
-
// src/preview/scaffold.ts
|
|
22
|
-
import { existsSync, mkdirSync, writeFileSync } from "fs";
|
|
23
|
-
import { dirname, join, resolve } from "path";
|
|
24
|
-
|
|
25
|
-
// src/preview/templates.ts
|
|
26
|
-
var VERSIONS = {
|
|
27
|
-
nuxt: "^4.0.0",
|
|
28
|
-
vue: "^3.5.0",
|
|
29
|
-
studio: "^0.1.3",
|
|
30
|
-
studioShared: "^0.2.0",
|
|
31
|
-
studioIntegrations: "^0.5.1",
|
|
32
|
-
vueFlowCore: "^1.48.2",
|
|
33
|
-
vueFlowBackground: "^1.3.2",
|
|
34
|
-
vueFlowControls: "^1.1.3",
|
|
35
|
-
vueFlowMinimap: "^1.5.4",
|
|
36
|
-
vueFlowNodeToolbar: "^1.1.1",
|
|
37
|
-
dagre: "^3.0.0",
|
|
38
|
-
lucide: "^1.0.0",
|
|
39
|
-
solarIcons: "^1.2.1",
|
|
40
|
-
// studio-integrations 0.5.x embeds a TipTap rich-text editor and vue-sonner toasts.
|
|
41
|
-
tiptap: "^3.28.0",
|
|
42
|
-
vueSonner: "^2.0.0",
|
|
43
|
-
tailwindVite: "^4.0.0",
|
|
44
|
-
tailwind: "^4.0.0"
|
|
45
|
-
};
|
|
46
|
-
var PACKAGE_JSON = `{
|
|
47
|
-
"name": "integrations-preview-host",
|
|
48
|
-
"private": true,
|
|
49
|
-
"type": "module",
|
|
50
|
-
"scripts": {
|
|
51
|
-
"dev": "nuxt dev",
|
|
52
|
-
"build": "nuxt build"
|
|
53
|
-
},
|
|
54
|
-
"dependencies": {
|
|
55
|
-
"@revenexx/studio": "${VERSIONS.studio}",
|
|
56
|
-
"@revenexx/studio-integrations": "${VERSIONS.studioIntegrations}",
|
|
57
|
-
"@revenexx/studio-shared": "${VERSIONS.studioShared}",
|
|
58
|
-
"@solar-icons/nuxt": "${VERSIONS.solarIcons}",
|
|
59
|
-
"@dagrejs/dagre": "${VERSIONS.dagre}",
|
|
60
|
-
"@tiptap/core": "${VERSIONS.tiptap}",
|
|
61
|
-
"@tiptap/extension-document": "${VERSIONS.tiptap}",
|
|
62
|
-
"@tiptap/extension-history": "${VERSIONS.tiptap}",
|
|
63
|
-
"@tiptap/extension-paragraph": "${VERSIONS.tiptap}",
|
|
64
|
-
"@tiptap/extension-text": "${VERSIONS.tiptap}",
|
|
65
|
-
"@tiptap/pm": "${VERSIONS.tiptap}",
|
|
66
|
-
"@tiptap/vue-3": "${VERSIONS.tiptap}",
|
|
67
|
-
"@vue-flow/background": "${VERSIONS.vueFlowBackground}",
|
|
68
|
-
"@vue-flow/controls": "${VERSIONS.vueFlowControls}",
|
|
69
|
-
"@vue-flow/core": "${VERSIONS.vueFlowCore}",
|
|
70
|
-
"@vue-flow/minimap": "${VERSIONS.vueFlowMinimap}",
|
|
71
|
-
"@vue-flow/node-toolbar": "${VERSIONS.vueFlowNodeToolbar}",
|
|
72
|
-
"lucide-vue-next": "${VERSIONS.lucide}",
|
|
73
|
-
"nuxt": "${VERSIONS.nuxt}",
|
|
74
|
-
"vue": "${VERSIONS.vue}",
|
|
75
|
-
"vue-sonner": "${VERSIONS.vueSonner}"
|
|
76
|
-
},
|
|
77
|
-
"devDependencies": {
|
|
78
|
-
"@tailwindcss/vite": "${VERSIONS.tailwindVite}",
|
|
79
|
-
"tailwindcss": "${VERSIONS.tailwind}"
|
|
80
|
-
}
|
|
81
|
-
}
|
|
82
|
-
`;
|
|
83
|
-
var NUXT_CONFIG = `import tailwindcss from '@tailwindcss/vite';
|
|
84
|
-
|
|
85
|
-
// Minimal preview host for local integration-node development.
|
|
86
|
-
// Generated by \`integrations-devkit init-preview\` \u2014 safe to edit or delete
|
|
87
|
-
// (it lives under the gitignored .revenexx-dev/).
|
|
88
|
-
export default defineNuxtConfig({
|
|
89
|
-
compatibilityDate: '2025-01-01',
|
|
90
|
-
// SPA: no SSR, so the studio's browser-only composables (localStorage etc.)
|
|
91
|
-
// behave exactly as in the real cockpit, and boot is fast.
|
|
92
|
-
ssr: false,
|
|
93
|
-
// studio-shared 0.2.x ships as a Nuxt MODULE (not a layer) \u2014 it must be
|
|
94
|
-
// registered in 'modules', before studio-integrations which builds on it.
|
|
95
|
-
// @solar-icons/nuxt provides the #solar-icons alias the studio components import.
|
|
96
|
-
modules: ['@revenexx/studio-shared', '@solar-icons/nuxt', '@revenexx/studio-integrations'],
|
|
97
|
-
css: ['~/assets/css/main.css'],
|
|
98
|
-
vite: { plugins: [tailwindcss()] },
|
|
99
|
-
runtimeConfig: {
|
|
100
|
-
public: {
|
|
101
|
-
// Overridden at runtime by NUXT_PUBLIC_* env (see .env / the preview command).
|
|
102
|
-
integrationsApi: '',
|
|
103
|
-
devToken: '',
|
|
104
|
-
devTenant: '',
|
|
105
|
-
},
|
|
106
|
-
},
|
|
107
|
-
});
|
|
108
|
-
`;
|
|
109
|
-
var MAIN_CSS = `@import "tailwindcss";
|
|
110
|
-
@import "@revenexx/studio/tokens";
|
|
111
|
-
@import "@revenexx/studio/fonts";
|
|
112
|
-
|
|
113
|
-
@source "../../node_modules/@revenexx/studio/dist";
|
|
114
|
-
@source "../../node_modules/@revenexx/studio-shared/components";
|
|
115
|
-
@source "../../node_modules/@revenexx/studio-integrations/dist/runtime";
|
|
116
|
-
|
|
117
|
-
/* Phase 1: workflow EXECUTION is not wired up in the devkit preview yet, so the
|
|
118
|
-
Workflows surface is hidden until phase 2. This hides the sidebar nav entry
|
|
119
|
-
and any deep links to the workflow editor; the routes are also redirected by
|
|
120
|
-
middleware/hide-workflows.global.ts. */
|
|
121
|
-
a[href^="/integrations/workflows"] { display: none !important; }
|
|
122
|
-
li:has(> a[href^="/integrations/workflows"]) { display: none !important; }
|
|
123
|
-
`;
|
|
124
|
-
var APP_VUE = `<script setup lang="ts">
|
|
125
|
-
import { Toaster } from '@revenexx/studio'
|
|
126
|
-
|
|
127
|
-
useHead({ title: 'Integration Studio \u2014 devkit preview' })
|
|
128
|
-
</script>
|
|
129
|
-
|
|
130
|
-
<template>
|
|
131
|
-
<div class="flex h-svh flex-col overflow-hidden bg-[#f3f1fa] text-foreground">
|
|
132
|
-
<NuxtLoadingIndicator color="var(--color-primary, #620DFF)" :height="3" />
|
|
133
|
-
<div class="min-h-0 flex-1 pt-3">
|
|
134
|
-
<NuxtPage />
|
|
135
|
-
</div>
|
|
136
|
-
<Toaster rich-colors position="bottom-right" :duration="3500" close-button />
|
|
137
|
-
</div>
|
|
138
|
-
</template>
|
|
139
|
-
`;
|
|
140
|
-
var INDEX_VUE = `<template>
|
|
141
|
-
<div class="mx-auto flex min-h-full max-w-xl flex-col justify-center gap-6 px-6 py-12">
|
|
142
|
-
<div>
|
|
143
|
-
<p class="text-mono text-muted-foreground">Integrations \xB7 node devkit</p>
|
|
144
|
-
<h1 class="mt-1 text-2xl font-medium">Integration Studio \u2014 Preview</h1>
|
|
145
|
-
<p class="mt-2 text-sm text-muted-foreground">
|
|
146
|
-
Lokaler Host f\xFCr <code>@revenexx/studio-integrations</code> gegen die Mock-API
|
|
147
|
-
deines Node-Pakets. Authentifizierung ist ein festes Dev-Token \u2014 nichts einzugeben.
|
|
148
|
-
</p>
|
|
149
|
-
</div>
|
|
150
|
-
|
|
151
|
-
<div class="rounded-lg border border-black/[0.06] bg-card p-5 text-sm shadow-sm">
|
|
152
|
-
<p class="text-mono text-muted-foreground">Session</p>
|
|
153
|
-
<dl class="mt-2 grid grid-cols-[7rem_1fr] gap-y-1">
|
|
154
|
-
<dt class="text-muted-foreground">Mock API</dt>
|
|
155
|
-
<dd class="truncate font-mono text-xs leading-5">{{ api }}</dd>
|
|
156
|
-
<dt class="text-muted-foreground">Tenant</dt>
|
|
157
|
-
<dd class="font-mono text-xs leading-5">{{ tenant }}</dd>
|
|
158
|
-
</dl>
|
|
159
|
-
</div>
|
|
160
|
-
|
|
161
|
-
<div class="rounded-lg border border-black/[0.06] bg-card p-5 shadow-sm">
|
|
162
|
-
<p class="text-mono text-muted-foreground">Einstieg</p>
|
|
163
|
-
<div class="mt-3 flex flex-col gap-4">
|
|
164
|
-
<NuxtLink
|
|
165
|
-
to="/nodes"
|
|
166
|
-
class="inline-flex w-fit items-center gap-2 rounded-md bg-primary px-4 py-2 text-sm font-medium text-primary-foreground hover:opacity-90"
|
|
167
|
-
>
|
|
168
|
-
Lokale Nodes \xF6ffnen \u2014 Preview + Validierung
|
|
169
|
-
</NuxtLink>
|
|
170
|
-
<div class="flex flex-wrap gap-x-4 gap-y-1.5">
|
|
171
|
-
<NuxtLink
|
|
172
|
-
v-for="link in quickLinks"
|
|
173
|
-
:key="link.to"
|
|
174
|
-
:to="link.to"
|
|
175
|
-
class="text-sm text-primary hover:underline"
|
|
176
|
-
>
|
|
177
|
-
{{ link.label }}
|
|
178
|
-
</NuxtLink>
|
|
179
|
-
</div>
|
|
180
|
-
</div>
|
|
181
|
-
</div>
|
|
182
|
-
</div>
|
|
183
|
-
</template>
|
|
184
|
-
|
|
185
|
-
<script setup lang="ts">
|
|
186
|
-
const rc = useRuntimeConfig().public
|
|
187
|
-
const api = rc.integrationsApi
|
|
188
|
-
const tenant = (rc.devTenant as string) || 'dev-tenant'
|
|
189
|
-
|
|
190
|
-
const quickLinks = [
|
|
191
|
-
{ to: '/integrations', label: 'Overview' },
|
|
192
|
-
{ to: '/integrations/credentials', label: 'Credentials' },
|
|
193
|
-
{ to: '/integrations/secrets', label: 'Secrets' },
|
|
194
|
-
{ to: '/nodes', label: 'Local nodes' },
|
|
195
|
-
]
|
|
196
|
-
</script>
|
|
197
|
-
`;
|
|
198
|
-
var NODES_VUE = `<template>
|
|
199
|
-
<div class="ndx-page">
|
|
200
|
-
<div class="ndx-inner">
|
|
201
|
-
<header class="ndx-head">
|
|
202
|
-
<h1>Lokale Nodes</h1>
|
|
203
|
-
<p>Mock-API: <code>{{ apiUrl }}</code></p>
|
|
204
|
-
<p v-if="loadError" class="ndx-err">{{ loadError }}</p>
|
|
205
|
-
</header>
|
|
206
|
-
|
|
207
|
-
<p v-if="loading">Lade Nodes\u2026</p>
|
|
208
|
-
<p v-else-if="nodes.length === 0">Keine Nodes gefunden. Exportiert dein Paket <code>NODES</code>?</p>
|
|
209
|
-
|
|
210
|
-
<ul v-else class="ndx-grid">
|
|
211
|
-
<li v-for="n in nodes" :key="n.slug + '@' + n.version" class="ndx-card" @click="openNode(n)">
|
|
212
|
-
<div class="ndx-card-title">{{ label(n) }}</div>
|
|
213
|
-
<div class="ndx-card-slug">{{ n.slug }} \xB7 v{{ n.version }}</div>
|
|
214
|
-
<div class="ndx-badges">
|
|
215
|
-
<span v-if="n.has_dynamic_options" class="ndx-badge">dynamic options</span>
|
|
216
|
-
<span v-if="n.has_dynamic_schema" class="ndx-badge">dynamic schema</span>
|
|
217
|
-
<span v-if="n.has_dynamic_outputs" class="ndx-badge">dynamic outputs</span>
|
|
218
|
-
</div>
|
|
219
|
-
</li>
|
|
220
|
-
</ul>
|
|
221
|
-
</div>
|
|
222
|
-
|
|
223
|
-
<!-- REUSE of the exact editor lightbox: studio <Dialog> owns the modal
|
|
224
|
-
chrome, <IntegrationsNodeInspector> is the content \u2014 mirrors
|
|
225
|
-
WorkflowEditor.vue's <Dialog><DialogContent><NodeInspector/> block. -->
|
|
226
|
-
<Dialog :open="!!selection" @update:open="(v) => { if (!v) requestClose() }">
|
|
227
|
-
<DialogContent :show-close-button="false" class="flex h-[min(680px,86vh)] w-[min(1100px,94vw)] max-w-none flex-col gap-0 overflow-hidden rounded-lg p-0 sm:max-w-none">
|
|
228
|
-
<div v-if="result === 'ok'" class="ndx-strip ndx-strip-ok">\u2713 Payload g\xFCltig \u2014 alles gut.</div>
|
|
229
|
-
<div v-else-if="result === 'err'" class="ndx-strip ndx-strip-err">\u2717 Payload ung\xFCltig \u2014 {{ errorCount }} Feld(er) pr\xFCfen (rot markiert).</div>
|
|
230
|
-
<div v-else-if="formError" class="ndx-strip ndx-strip-err">{{ formError }}</div>
|
|
231
|
-
<IntegrationsNodeInspector
|
|
232
|
-
v-if="selection"
|
|
233
|
-
:selection="selection"
|
|
234
|
-
:secret-keys="secretKeys"
|
|
235
|
-
:refused-fields="refused"
|
|
236
|
-
@update="onSubmit"
|
|
237
|
-
@close="requestClose" />
|
|
238
|
-
</DialogContent>
|
|
239
|
-
</Dialog>
|
|
240
|
-
</div>
|
|
241
|
-
</template>
|
|
242
|
-
|
|
243
|
-
<script setup lang="ts">
|
|
244
|
-
import { computed, onMounted, ref } from 'vue'
|
|
245
|
-
import { Dialog, DialogContent } from '@revenexx/studio'
|
|
246
|
-
|
|
247
|
-
interface ApiNode {
|
|
248
|
-
name: string | Record<string, string>
|
|
249
|
-
slug: string
|
|
250
|
-
version: string
|
|
251
|
-
manifest?: { name?: string | Record<string, string> }
|
|
252
|
-
has_dynamic_options?: boolean
|
|
253
|
-
has_dynamic_schema?: boolean
|
|
254
|
-
has_dynamic_outputs?: boolean
|
|
255
|
-
}
|
|
256
|
-
|
|
257
|
-
const apiUrl = useRuntimeConfig().public.integrationsApi
|
|
258
|
-
const client = useIntegrationsApi()
|
|
259
|
-
// load() fills the reactive catalog the inspector reads via findManifest();
|
|
260
|
-
// resolveLocalized() turns a LocalizedString into the active-locale string.
|
|
261
|
-
const { load, resolveLocalized } = useIntegrationsNodes()
|
|
262
|
-
|
|
263
|
-
const nodes = ref<ApiNode[]>([])
|
|
264
|
-
const loading = ref(true)
|
|
265
|
-
const loadError = ref<string | null>(null)
|
|
266
|
-
|
|
267
|
-
const selection = ref<any>(null)
|
|
268
|
-
const secretKeys = ref<string[]>([])
|
|
269
|
-
const refused = ref<Record<string, string>>({})
|
|
270
|
-
const result = ref<string | null>(null)
|
|
271
|
-
const formError = ref<string | null>(null)
|
|
272
|
-
// Set synchronously in onSubmit so the inspector's own Save (it emits update THEN
|
|
273
|
-
// close) does NOT close the dialog \u2014 we keep it open to show the verdict.
|
|
274
|
-
const validating = ref(false)
|
|
275
|
-
|
|
276
|
-
const errorCount = computed(() => Object.keys(refused.value).length)
|
|
277
|
-
|
|
278
|
-
function label(n: ApiNode): string {
|
|
279
|
-
return resolveLocalized(n.manifest?.name ?? n.name) || n.slug
|
|
280
|
-
}
|
|
281
|
-
|
|
282
|
-
onMounted(async () => {
|
|
283
|
-
await load()
|
|
284
|
-
try {
|
|
285
|
-
const res = await client.get<any>('/nodes')
|
|
286
|
-
nodes.value = (Array.isArray(res) ? res : res?.data ?? []) as ApiNode[]
|
|
287
|
-
} catch (e: any) {
|
|
288
|
-
loadError.value = e?.message ?? 'Nodes konnten nicht geladen werden.'
|
|
289
|
-
} finally {
|
|
290
|
-
loading.value = false
|
|
291
|
-
}
|
|
292
|
-
try {
|
|
293
|
-
const secrets = await client.get<any>('/secrets')
|
|
294
|
-
const list = (Array.isArray(secrets) ? secrets : secrets?.data ?? []) as Array<{ key: string }>
|
|
295
|
-
secretKeys.value = list.map(s => s.key).filter(Boolean)
|
|
296
|
-
} catch {
|
|
297
|
-
// secrets are optional for the preview
|
|
298
|
-
}
|
|
299
|
-
})
|
|
300
|
-
|
|
301
|
-
function openNode(n: ApiNode) {
|
|
302
|
-
refused.value = {}
|
|
303
|
-
result.value = null
|
|
304
|
-
formError.value = null
|
|
305
|
-
// Synthetic WorkflowNode selection (distinguished by nodeSlug); the inspector
|
|
306
|
-
// resolves its manifest from the catalog load() populated above.
|
|
307
|
-
selection.value = { id: 'preview', nodeSlug: n.slug, nodeVersion: n.version, name: label(n), config: {} }
|
|
308
|
-
}
|
|
309
|
-
|
|
310
|
-
async function onSubmit(draft: any) {
|
|
311
|
-
validating.value = true
|
|
312
|
-
refused.value = {}
|
|
313
|
-
result.value = null
|
|
314
|
-
formError.value = null
|
|
315
|
-
try {
|
|
316
|
-
const slug = encodeURIComponent(draft.nodeSlug)
|
|
317
|
-
const version = encodeURIComponent(draft.nodeVersion || 'latest')
|
|
318
|
-
const res = await client.post<any>(
|
|
319
|
-
'/nodes/' + slug + '/' + version + '/config:validate',
|
|
320
|
-
{ config: draft.config ?? {} },
|
|
321
|
-
)
|
|
322
|
-
if (res.valid) {
|
|
323
|
-
result.value = 'ok'
|
|
324
|
-
} else {
|
|
325
|
-
refused.value = Object.fromEntries(
|
|
326
|
-
Object.entries(res.errors ?? {}).map(([k, msgs]) => [k, (msgs as string[]).join(' ')]),
|
|
327
|
-
)
|
|
328
|
-
result.value = 'err'
|
|
329
|
-
}
|
|
330
|
-
} catch (e: any) {
|
|
331
|
-
formError.value = e?.message ?? 'Validierung fehlgeschlagen.'
|
|
332
|
-
} finally {
|
|
333
|
-
validating.value = false
|
|
334
|
-
}
|
|
335
|
-
}
|
|
20
|
+
import { fileURLToPath as fileURLToPath2 } from "url";
|
|
336
21
|
|
|
337
|
-
//
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
}
|
|
347
|
-
</script>
|
|
348
|
-
|
|
349
|
-
<style scoped>
|
|
350
|
-
/* The app shell (app.vue) is h-svh + overflow-hidden, so this page must own its
|
|
351
|
-
own vertical scroll \u2014 otherwise the node list is clipped and can't scroll. */
|
|
352
|
-
.ndx-page { height: 100%; overflow-y: auto; }
|
|
353
|
-
.ndx-inner { max-width: 60rem; margin: 0 auto; padding: 2rem; font-family: sans-serif; }
|
|
354
|
-
.ndx-head h1 { font-size: 1.5rem; font-weight: 600; }
|
|
355
|
-
.ndx-err { color: #b91c1c; }
|
|
356
|
-
.ndx-grid { list-style: none; padding: 0; display: grid; grid-template-columns: repeat(auto-fill, minmax(15rem, 1fr)); gap: 1rem; margin-top: 1.5rem; }
|
|
357
|
-
.ndx-card { border: 1px solid #d1d5db; border-radius: 0.5rem; padding: 1rem; cursor: pointer; transition: border-color .15s, box-shadow .15s; }
|
|
358
|
-
.ndx-card:hover { border-color: #6366f1; box-shadow: 0 1px 6px rgba(0,0,0,.08); }
|
|
359
|
-
.ndx-card-title { font-weight: 600; }
|
|
360
|
-
.ndx-card-slug { color: #6b7280; font-size: .85rem; margin-top: .25rem; }
|
|
361
|
-
.ndx-badges { margin-top: .5rem; display: flex; flex-wrap: wrap; gap: .35rem; }
|
|
362
|
-
.ndx-badge { font-size: .7rem; background: #eef2ff; color: #4338ca; border-radius: .25rem; padding: .1rem .4rem; }
|
|
363
|
-
|
|
364
|
-
/* Verdict strip shown at the top of the reused dialog content (does not close). */
|
|
365
|
-
.ndx-strip { flex: 0 0 auto; padding: .5rem 1rem; font-size: .85rem; font-weight: 600; }
|
|
366
|
-
.ndx-strip-ok { background: #dcfce7; color: #166534; }
|
|
367
|
-
.ndx-strip-err { background: #fee2e2; color: #991b1b; }
|
|
368
|
-
</style>
|
|
369
|
-
`;
|
|
370
|
-
var GITIGNORE = `node_modules/
|
|
22
|
+
// src/preview/host.ts
|
|
23
|
+
import { createHash } from "crypto";
|
|
24
|
+
import { cpSync, existsSync, mkdirSync, readFileSync, rmSync, writeFileSync } from "fs";
|
|
25
|
+
import { homedir } from "os";
|
|
26
|
+
import { dirname, join, relative, resolve, sep } from "path";
|
|
27
|
+
import { fileURLToPath } from "url";
|
|
28
|
+
var INSTALL_MARKER = ".devkit-install-complete";
|
|
29
|
+
var COPY_MARKER = ".devkit-copy-complete";
|
|
30
|
+
var HOST_GITIGNORE = `node_modules/
|
|
371
31
|
.nuxt/
|
|
32
|
+
.nuxt-*/
|
|
372
33
|
.output/
|
|
373
34
|
.data/
|
|
35
|
+
.env
|
|
36
|
+
${COPY_MARKER}
|
|
37
|
+
${INSTALL_MARKER}
|
|
374
38
|
`;
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
return { tenants: ref([]), onlyTenantSlug: ref(null), load: async () => {} }
|
|
39
|
+
function resolveHostDir(options) {
|
|
40
|
+
const root = options.cacheRoot ?? process.env.XDG_CACHE_HOME ?? join(homedir(), ".cache");
|
|
41
|
+
return join(root, "revenexx", "devkit-preview", options.version);
|
|
379
42
|
}
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
|
|
43
|
+
function shippedHostDir() {
|
|
44
|
+
let dir = dirname(fileURLToPath(import.meta.url));
|
|
45
|
+
for (let up = 0; up < 5; up += 1) {
|
|
46
|
+
const candidate = join(dir, "preview-host");
|
|
47
|
+
if (existsSync(join(candidate, "nuxt.config.ts"))) {
|
|
48
|
+
return candidate;
|
|
49
|
+
}
|
|
50
|
+
const parent = dirname(dir);
|
|
51
|
+
if (parent === dir) break;
|
|
52
|
+
dir = parent;
|
|
387
53
|
}
|
|
54
|
+
throw new Error("Preview host not found: no preview-host/nuxt.config.ts above this module. Reinstall @revenexx/integrations-node-devkit.");
|
|
388
55
|
}
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
|
|
56
|
+
function materializeHost(options) {
|
|
57
|
+
const log = options.log ?? (() => {
|
|
58
|
+
});
|
|
59
|
+
const source = options.sourceDir ?? shippedHostDir();
|
|
60
|
+
const dir = resolve(options.targetDir);
|
|
61
|
+
const managed = options.managed ?? false;
|
|
62
|
+
const intact = managed ? hostIsComplete(dir) : hostExists(dir);
|
|
63
|
+
const alreadyIntact = intact && !options.force;
|
|
64
|
+
if (!alreadyIntact) {
|
|
65
|
+
mkdirSync(dir, { recursive: true });
|
|
66
|
+
rmSync(join(dir, COPY_MARKER), { force: true });
|
|
67
|
+
cpSync(source, dir, { recursive: true, filter: (src) => !isInsideNodeModules(source, src) });
|
|
68
|
+
writeFileSync(join(dir, COPY_MARKER), `${(/* @__PURE__ */ new Date()).toISOString()}
|
|
69
|
+
`, "utf-8");
|
|
70
|
+
writeFileSync(join(dir, ".gitignore"), HOST_GITIGNORE, "utf-8");
|
|
71
|
+
log(`Preview host ready in ${dir}`);
|
|
396
72
|
}
|
|
397
|
-
|
|
398
|
-
|
|
399
|
-
|
|
400
|
-
listCredentials: async () => [],
|
|
401
|
-
getCredential: async () => ({}),
|
|
402
|
-
createCredential: async () => ({}),
|
|
73
|
+
const envPath = join(dir, ".env");
|
|
74
|
+
if (managed || !existsSync(envPath)) {
|
|
75
|
+
writeFileSync(envPath, envFile(options), "utf-8");
|
|
403
76
|
}
|
|
77
|
+
return { dir, copied: !alreadyIntact };
|
|
404
78
|
}
|
|
405
|
-
|
|
406
|
-
|
|
79
|
+
function isInsideNodeModules(source, src) {
|
|
80
|
+
const rel = relative(source, src);
|
|
81
|
+
return rel !== "" && rel.split(sep).includes("node_modules");
|
|
407
82
|
}
|
|
408
|
-
|
|
409
|
-
|
|
410
|
-
|
|
411
|
-
|
|
412
|
-
}
|
|
413
|
-
})
|
|
414
|
-
`;
|
|
415
|
-
function previewTemplates(options) {
|
|
416
|
-
const env = `# Overrides the Nuxt runtimeConfig.public.* values.
|
|
83
|
+
function envFile(options) {
|
|
84
|
+
return `# Generated by integrations-devkit \u2014 overrides the Nuxt runtimeConfig.public.* values.
|
|
85
|
+
# The \`preview\` command also passes these to the Nuxt child process; this file is
|
|
86
|
+
# what makes a manual \`npm run dev\` in this directory work.
|
|
417
87
|
NUXT_PUBLIC_INTEGRATIONS_API=${options.integrationsApiUrl}
|
|
418
|
-
NUXT_PUBLIC_DEV_TOKEN
|
|
419
|
-
NUXT_PUBLIC_DEV_TENANT
|
|
88
|
+
NUXT_PUBLIC_DEV_TOKEN=${options.devToken ?? "dev"}
|
|
89
|
+
NUXT_PUBLIC_DEV_TENANT=${options.devTenant ?? "dev-tenant"}
|
|
420
90
|
`;
|
|
421
|
-
return {
|
|
422
|
-
"package.json": PACKAGE_JSON,
|
|
423
|
-
"nuxt.config.ts": NUXT_CONFIG,
|
|
424
|
-
"assets/css/main.css": MAIN_CSS,
|
|
425
|
-
"app.vue": APP_VUE,
|
|
426
|
-
"pages/index.vue": INDEX_VUE,
|
|
427
|
-
"pages/nodes.vue": NODES_VUE,
|
|
428
|
-
"composables/devkit-console-stubs.ts": CONSOLE_STUBS,
|
|
429
|
-
"middleware/hide-workflows.global.ts": HIDE_WORKFLOWS_MW,
|
|
430
|
-
".env": env,
|
|
431
|
-
".gitignore": GITIGNORE
|
|
432
|
-
};
|
|
433
91
|
}
|
|
434
|
-
|
|
435
|
-
|
|
436
|
-
|
|
437
|
-
|
|
438
|
-
|
|
439
|
-
|
|
440
|
-
|
|
441
|
-
|
|
442
|
-
|
|
443
|
-
|
|
444
|
-
|
|
445
|
-
|
|
446
|
-
|
|
447
|
-
|
|
448
|
-
mkdirSync(dirname(target), { recursive: true });
|
|
449
|
-
writeFileSync(target, content, "utf-8");
|
|
450
|
-
written.push(relative);
|
|
451
|
-
}
|
|
452
|
-
if (written.length > 0) {
|
|
453
|
-
log(`Scaffolded preview host in ${options.dir} (${written.length} file(s)).`);
|
|
92
|
+
function hostBuildDir(hostDir, consumerDir) {
|
|
93
|
+
const key = createHash("sha256").update(consumerDir).digest("hex").slice(0, 12);
|
|
94
|
+
return join(hostDir, `.nuxt-${key}`);
|
|
95
|
+
}
|
|
96
|
+
function hostExists(dir) {
|
|
97
|
+
return existsSync(join(dir, "package.json")) && existsSync(join(dir, "nuxt.config.ts"));
|
|
98
|
+
}
|
|
99
|
+
function hostIsComplete(dir) {
|
|
100
|
+
return hostExists(dir) && existsSync(join(dir, COPY_MARKER));
|
|
101
|
+
}
|
|
102
|
+
function hostNeedsInstall(dir) {
|
|
103
|
+
const marker = join(dir, INSTALL_MARKER);
|
|
104
|
+
if (!existsSync(join(dir, "node_modules")) || !existsSync(marker)) {
|
|
105
|
+
return true;
|
|
454
106
|
}
|
|
455
|
-
|
|
456
|
-
|
|
107
|
+
try {
|
|
108
|
+
return readFileSync(marker, "utf-8").trim() !== manifestFingerprint(dir);
|
|
109
|
+
} catch {
|
|
110
|
+
return true;
|
|
457
111
|
}
|
|
458
|
-
return { dir: options.dir, written, skipped };
|
|
459
112
|
}
|
|
460
|
-
function
|
|
461
|
-
|
|
113
|
+
function markHostInstalled(dir) {
|
|
114
|
+
writeFileSync(join(dir, INSTALL_MARKER), `${manifestFingerprint(dir)}
|
|
115
|
+
`, "utf-8");
|
|
462
116
|
}
|
|
463
|
-
function
|
|
464
|
-
|
|
117
|
+
function clearHostInstallMarker(dir) {
|
|
118
|
+
rmSync(join(dir, INSTALL_MARKER), { force: true });
|
|
119
|
+
}
|
|
120
|
+
function manifestFingerprint(dir) {
|
|
121
|
+
const pkg = JSON.parse(readFileSync(join(dir, "package.json"), "utf-8"));
|
|
122
|
+
return JSON.stringify({ dependencies: pkg.dependencies ?? {}, devDependencies: pkg.devDependencies ?? {} });
|
|
465
123
|
}
|
|
466
124
|
|
|
467
125
|
// src/cli.ts
|
|
@@ -476,7 +134,7 @@ function parseArgs(argv) {
|
|
|
476
134
|
uiDir: null,
|
|
477
135
|
serveUi: true,
|
|
478
136
|
open: false,
|
|
479
|
-
previewDir:
|
|
137
|
+
previewDir: null,
|
|
480
138
|
force: false
|
|
481
139
|
};
|
|
482
140
|
let command = null;
|
|
@@ -523,7 +181,8 @@ function parseArgs(argv) {
|
|
|
523
181
|
opts.open = true;
|
|
524
182
|
break;
|
|
525
183
|
// Both are consumed by loadEnvFile() before parsing; listed here so they
|
|
526
|
-
// do not fall through to the unknown-option branch.
|
|
184
|
+
// do not fall through to the unknown-option branch. A repeated `--env`
|
|
185
|
+
// resolves to the last one, so each occurrence skips its own value.
|
|
527
186
|
case "--env":
|
|
528
187
|
i++;
|
|
529
188
|
break;
|
|
@@ -553,7 +212,7 @@ function parseArgs(argv) {
|
|
|
553
212
|
return { command, options: opts };
|
|
554
213
|
}
|
|
555
214
|
function loadSchemas() {
|
|
556
|
-
const here =
|
|
215
|
+
const here = fileURLToPath2(new URL(".", import.meta.url));
|
|
557
216
|
const schemasDir = resolve2(here, "..", "assets", "schemas");
|
|
558
217
|
const schemas = {};
|
|
559
218
|
if (!existsSync2(schemasDir)) {
|
|
@@ -563,7 +222,7 @@ function loadSchemas() {
|
|
|
563
222
|
if (extname(file) !== ".json") {
|
|
564
223
|
continue;
|
|
565
224
|
}
|
|
566
|
-
const parsed = JSON.parse(
|
|
225
|
+
const parsed = JSON.parse(readFileSync2(join2(schemasDir, file), "utf-8"));
|
|
567
226
|
const base = file.replace(/\.json$/, "");
|
|
568
227
|
const dash = base.indexOf("-");
|
|
569
228
|
if (dash > 0) {
|
|
@@ -608,8 +267,8 @@ var MIME = {
|
|
|
608
267
|
};
|
|
609
268
|
function serveStatic(uiDir, req, res) {
|
|
610
269
|
const url = new URL(req.url ?? "/", "http://localhost");
|
|
611
|
-
const
|
|
612
|
-
let filePath = resolve2(uiDir,
|
|
270
|
+
const relative2 = url.pathname === "/" ? "index.html" : url.pathname.replace(/^\/+/, "");
|
|
271
|
+
let filePath = resolve2(uiDir, relative2);
|
|
613
272
|
if (!filePath.startsWith(uiDir) || !existsSync2(filePath)) {
|
|
614
273
|
filePath = join2(uiDir, "index.html");
|
|
615
274
|
}
|
|
@@ -618,7 +277,7 @@ function serveStatic(uiDir, req, res) {
|
|
|
618
277
|
return;
|
|
619
278
|
}
|
|
620
279
|
res.writeHead(200, { "Content-Type": MIME[extname(filePath)] ?? "application/octet-stream" });
|
|
621
|
-
res.end(
|
|
280
|
+
res.end(readFileSync2(filePath));
|
|
622
281
|
}
|
|
623
282
|
async function startMock(options) {
|
|
624
283
|
let loaded = await loadPackageFromEntry(options.entry);
|
|
@@ -696,7 +355,7 @@ function watchAndReload(entry, onChange) {
|
|
|
696
355
|
let timer;
|
|
697
356
|
try {
|
|
698
357
|
const watcher = watch(dir, { recursive: true }, (_event, file) => {
|
|
699
|
-
if (file &&
|
|
358
|
+
if (file && isReloadableSource(file.toString())) {
|
|
700
359
|
clearTimeout(timer);
|
|
701
360
|
timer = setTimeout(onChange, 200);
|
|
702
361
|
}
|
|
@@ -715,15 +374,34 @@ async function runNpmInstall(dir) {
|
|
|
715
374
|
child.on("error", reject);
|
|
716
375
|
});
|
|
717
376
|
}
|
|
377
|
+
function noteLegacyPreviewDir() {
|
|
378
|
+
const legacy = resolve2(process.cwd(), ".revenexx-dev/preview");
|
|
379
|
+
if (existsSync2(legacy)) {
|
|
380
|
+
console.log(`Note: ${legacy} is no longer used \u2014 the preview host now lives in a shared cache. You can delete it to reclaim the space.`);
|
|
381
|
+
}
|
|
382
|
+
}
|
|
718
383
|
async function preview(options) {
|
|
719
|
-
const dir = options.previewDir;
|
|
720
384
|
const apiUrl = `http://localhost:${options.port}/api/v1`;
|
|
721
|
-
|
|
722
|
-
|
|
385
|
+
const managed = options.previewDir === null;
|
|
386
|
+
const targetDir = options.previewDir ?? resolveHostDir({ version: DEVKIT_VERSION });
|
|
387
|
+
noteLegacyPreviewDir();
|
|
388
|
+
const { dir } = materializeHost({
|
|
389
|
+
targetDir,
|
|
390
|
+
integrationsApiUrl: apiUrl,
|
|
391
|
+
force: options.force,
|
|
392
|
+
managed,
|
|
393
|
+
log: (msg) => console.log(msg)
|
|
394
|
+
});
|
|
395
|
+
if (managed) {
|
|
396
|
+
console.log(` Host (devkit ${DEVKIT_VERSION}, shared across repos) ${dir}`);
|
|
723
397
|
}
|
|
724
|
-
if (
|
|
725
|
-
|
|
398
|
+
if (options.force) {
|
|
399
|
+
clearHostInstallMarker(dir);
|
|
400
|
+
}
|
|
401
|
+
if (hostNeedsInstall(dir)) {
|
|
402
|
+
console.log("Installing preview-host dependencies (this pulls Nuxt + the studio packages and may take a while)\u2026");
|
|
726
403
|
await runNpmInstall(dir);
|
|
404
|
+
markHostInstalled(dir);
|
|
727
405
|
}
|
|
728
406
|
const mock = await startMock({ ...options, serveUi: false });
|
|
729
407
|
console.log(`
|
|
@@ -737,7 +415,10 @@ async function preview(options) {
|
|
|
737
415
|
...process.env,
|
|
738
416
|
NUXT_PUBLIC_INTEGRATIONS_API: apiUrl,
|
|
739
417
|
NUXT_PUBLIC_DEV_TOKEN: process.env.NUXT_PUBLIC_DEV_TOKEN ?? "dev",
|
|
740
|
-
NUXT_PUBLIC_DEV_TENANT: process.env.NUXT_PUBLIC_DEV_TENANT ?? "dev-tenant"
|
|
418
|
+
NUXT_PUBLIC_DEV_TENANT: process.env.NUXT_PUBLIC_DEV_TENANT ?? "dev-tenant",
|
|
419
|
+
// Keep the shared host's dependency install shared but its BUILD per repo,
|
|
420
|
+
// so two node packages previewing at once do not compile over each other.
|
|
421
|
+
DEVKIT_NUXT_BUILD_DIR: hostBuildDir(dir, process.cwd())
|
|
741
422
|
}
|
|
742
423
|
});
|
|
743
424
|
const shutdown = () => {
|
|
@@ -759,30 +440,37 @@ async function openBrowser(url) {
|
|
|
759
440
|
}
|
|
760
441
|
async function main() {
|
|
761
442
|
const argv = process.argv.slice(2);
|
|
762
|
-
const
|
|
443
|
+
const envFile2 = loadEnvFile(argv);
|
|
763
444
|
const { command, options } = parseArgs(argv);
|
|
764
445
|
if (command === "version") {
|
|
765
446
|
console.log(DEVKIT_VERSION);
|
|
766
447
|
return;
|
|
767
448
|
}
|
|
768
|
-
if (
|
|
769
|
-
console.log(`Loaded env from ${
|
|
449
|
+
if (envFile2) {
|
|
450
|
+
console.log(`Loaded env from ${envFile2}`);
|
|
770
451
|
}
|
|
771
452
|
if (command === "reset") {
|
|
772
|
-
const { rmSync } = await import("fs");
|
|
773
|
-
|
|
453
|
+
const { rmSync: rmSync2 } = await import("fs");
|
|
454
|
+
rmSync2(options.stateFile, { force: true });
|
|
774
455
|
console.log(`Removed ${options.stateFile}`);
|
|
775
456
|
return;
|
|
776
457
|
}
|
|
777
458
|
if (command === "init-preview") {
|
|
778
|
-
|
|
779
|
-
|
|
459
|
+
if (options.previewDir === null) {
|
|
460
|
+
console.error("init-preview needs an explicit target: `integrations-devkit init-preview --dir ./my-preview`.");
|
|
461
|
+
console.error("It exists to give you an UNMANAGED copy of the preview host to modify. For the normal preview, just run `integrations-devkit preview` \u2014");
|
|
462
|
+
console.error("that materializes the host into a shared cache and keeps it in step with the devkit version.");
|
|
463
|
+
process.exit(1);
|
|
464
|
+
}
|
|
465
|
+
const { dir } = materializeHost({
|
|
466
|
+
targetDir: options.previewDir,
|
|
780
467
|
integrationsApiUrl: `http://localhost:${options.port}/api/v1`,
|
|
781
468
|
force: options.force,
|
|
782
469
|
log: (msg) => console.log(msg)
|
|
783
470
|
});
|
|
784
|
-
console.log(
|
|
785
|
-
|
|
471
|
+
console.log("\nThis copy is yours and will NOT be updated by devkit upgrades.");
|
|
472
|
+
console.log(`Run it with: \`cd ${dir} && npm install && npm run dev\` (plus \`integrations-devkit --no-ui\` for the mock),`);
|
|
473
|
+
console.log(`or \`integrations-devkit preview --dir ${dir}\` to have both started for you.`);
|
|
786
474
|
return;
|
|
787
475
|
}
|
|
788
476
|
if (command === "preview") {
|