@pacaf/wizard-ux 2.0.0 → 3.0.1
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/LICENSE +21 -0
- package/package.json +11 -10
- package/server/index.mjs +26 -17
- package/server/routes/system.mjs +1 -1
- package/server/steps/01-prerequisites.mjs +1 -1
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 Microsoft Corporation
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@pacaf/wizard-ux",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "3.0.1",
|
|
4
4
|
"private": false,
|
|
5
5
|
"type": "module",
|
|
6
6
|
"description": "Browser-based setup wizard for Power Apps Code Apps (parallel to @pacaf/wizard CLI).",
|
|
@@ -22,12 +22,6 @@
|
|
|
22
22
|
"index.html",
|
|
23
23
|
"README.md"
|
|
24
24
|
],
|
|
25
|
-
"scripts": {
|
|
26
|
-
"dev": "node server/index.mjs",
|
|
27
|
-
"build": "vite build",
|
|
28
|
-
"preview": "vite preview --port 5174",
|
|
29
|
-
"postinstall": "node scripts/fix-pty-perms.mjs"
|
|
30
|
-
},
|
|
31
25
|
"dependencies": {
|
|
32
26
|
"@fastify/cors": "^9.0.1",
|
|
33
27
|
"@fastify/static": "^7.0.4",
|
|
@@ -43,7 +37,8 @@
|
|
|
43
37
|
"react": "^19.0.0",
|
|
44
38
|
"react-dom": "^19.0.0",
|
|
45
39
|
"react-resizable-panels": "^2.1.7",
|
|
46
|
-
"react-router-dom": "^7.1.0"
|
|
40
|
+
"react-router-dom": "^7.1.0",
|
|
41
|
+
"@pacaf/wizard": "3.0.1"
|
|
47
42
|
},
|
|
48
43
|
"devDependencies": {
|
|
49
44
|
"@types/react": "^19.0.0",
|
|
@@ -63,5 +58,11 @@
|
|
|
63
58
|
"scaffold",
|
|
64
59
|
"browser",
|
|
65
60
|
"pacaf"
|
|
66
|
-
]
|
|
67
|
-
|
|
61
|
+
],
|
|
62
|
+
"scripts": {
|
|
63
|
+
"dev": "node server/index.mjs",
|
|
64
|
+
"build": "vite build",
|
|
65
|
+
"preview": "vite preview --port 5174",
|
|
66
|
+
"postinstall": "node scripts/fix-pty-perms.mjs"
|
|
67
|
+
}
|
|
68
|
+
}
|
package/server/index.mjs
CHANGED
|
@@ -7,7 +7,6 @@ import { resolve, dirname, join } from 'node:path';
|
|
|
7
7
|
import { fileURLToPath } from 'node:url';
|
|
8
8
|
import { randomBytes } from 'node:crypto';
|
|
9
9
|
import { spawn } from 'node:child_process';
|
|
10
|
-
import { createServer as createViteServer } from 'vite';
|
|
11
10
|
|
|
12
11
|
import stateRoutes from './routes/state.mjs';
|
|
13
12
|
import systemRoutes from './routes/system.mjs';
|
|
@@ -22,7 +21,9 @@ const ROOT_DIR = resolve(UX_DIR, '..');
|
|
|
22
21
|
|
|
23
22
|
const HOST = '127.0.0.1';
|
|
24
23
|
const PORT = Number(process.env.WIZARD_UX_PORT || 5174);
|
|
25
|
-
|
|
24
|
+
// When installed as a published package, dist/ is always shipped and vite is
|
|
25
|
+
// not a runtime dep. Only treat this as "dev mode" when the caller opts in.
|
|
26
|
+
const IS_DEV = process.env.NODE_ENV === 'development' || process.env.WIZARD_UX_DEV === '1';
|
|
26
27
|
|
|
27
28
|
const CSRF_TOKEN = randomBytes(24).toString('hex');
|
|
28
29
|
|
|
@@ -36,7 +37,7 @@ await app.register(cors, {
|
|
|
36
37
|
// Otherwise only accept the well-known localhost origins.
|
|
37
38
|
if (!origin) return cb(null, true);
|
|
38
39
|
if (origin === `http://${HOST}:${PORT}` || origin === `http://localhost:${PORT}`) return cb(null, true);
|
|
39
|
-
if (
|
|
40
|
+
if (IS_DEV && (origin === `http://${HOST}:5175` || origin === 'http://localhost:5175')) return cb(null, true);
|
|
40
41
|
cb(new Error('Origin not allowed'), false);
|
|
41
42
|
},
|
|
42
43
|
credentials: true,
|
|
@@ -75,21 +76,26 @@ await app.register(streamRoutes, { prefix: '/api/steps', rootDir: ROOT_DIR });
|
|
|
75
76
|
await app.register(ptyRoutes, { rootDir: ROOT_DIR, csrfToken: CSRF_TOKEN });
|
|
76
77
|
await app.register(onepasswordRoutes, { prefix: '/api/1password' });
|
|
77
78
|
|
|
78
|
-
// Serve the UI —
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
}
|
|
90
|
-
|
|
79
|
+
// Serve the UI — prebuilt dist/ by default; vite middleware only in dev mode
|
|
80
|
+
const distDir = join(UX_DIR, 'dist');
|
|
81
|
+
const haveDist = existsSync(distDir);
|
|
82
|
+
|
|
83
|
+
if (!IS_DEV && haveDist) {
|
|
84
|
+
const fastifyStatic = (await import('@fastify/static')).default;
|
|
85
|
+
await app.register(fastifyStatic, { root: distDir, prefix: '/' });
|
|
86
|
+
app.setNotFoundHandler((req, reply) => {
|
|
87
|
+
if (req.url.startsWith('/api/')) return reply.code(404).send({ error: 'Not found' });
|
|
88
|
+
// SPA fallback
|
|
89
|
+
reply.sendFile('index.html');
|
|
90
|
+
});
|
|
91
|
+
} else if (IS_DEV) {
|
|
92
|
+
let createViteServer;
|
|
93
|
+
try {
|
|
94
|
+
({ createServer: createViteServer } = await import('vite'));
|
|
95
|
+
} catch (err) {
|
|
96
|
+
app.log.error('Dev mode requested (NODE_ENV=development or WIZARD_UX_DEV=1) but `vite` is not installed. Install it as a devDependency or run without WIZARD_UX_DEV.');
|
|
97
|
+
throw err;
|
|
91
98
|
}
|
|
92
|
-
} else {
|
|
93
99
|
const vite = await createViteServer({
|
|
94
100
|
root: UX_DIR,
|
|
95
101
|
server: { middlewareMode: true, hmr: { port: 5176 } },
|
|
@@ -113,6 +119,9 @@ if (IS_PROD) {
|
|
|
113
119
|
reply.code(500).send(String(e));
|
|
114
120
|
}
|
|
115
121
|
});
|
|
122
|
+
} else {
|
|
123
|
+
app.log.error(`No prebuilt UI found at ${distDir} and dev mode is not enabled. Reinstall @pacaf/wizard-ux or set WIZARD_UX_DEV=1.`);
|
|
124
|
+
throw new Error('wizard-ux/dist missing');
|
|
116
125
|
}
|
|
117
126
|
|
|
118
127
|
await app.listen({ host: HOST, port: PORT });
|
package/server/routes/system.mjs
CHANGED
|
@@ -3,7 +3,7 @@ import { execSync, execFileSync } from 'node:child_process';
|
|
|
3
3
|
import { existsSync } from 'node:fs';
|
|
4
4
|
import { join } from 'node:path';
|
|
5
5
|
import { homedir, platform, release } from 'node:os';
|
|
6
|
-
import { pacPath as resolvePacPath, runSafe } from '
|
|
6
|
+
import { pacPath as resolvePacPath, runSafe } from '@pacaf/wizard/lib/shell.mjs';
|
|
7
7
|
|
|
8
8
|
function safeRun(cmd) {
|
|
9
9
|
try { return execSync(cmd, { encoding: 'utf-8', stdio: ['pipe', 'pipe', 'pipe'] }).trim(); }
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
// Step 1 — Prerequisites. Read-only checks, no questions.
|
|
2
2
|
import { platform } from 'node:os';
|
|
3
3
|
import { execFileSync, execSync } from 'node:child_process';
|
|
4
|
-
import { pacPath, runSafe } from '
|
|
4
|
+
import { pacPath, runSafe } from '@pacaf/wizard/lib/shell.mjs';
|
|
5
5
|
|
|
6
6
|
function hasCommand(name) {
|
|
7
7
|
try {
|