@pulse-editor/cli 0.1.13 → 0.1.15
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.
|
@@ -1,62 +1,17 @@
|
|
|
1
1
|
import { Fragment as _Fragment, jsx as _jsx } from "react/jsx-runtime";
|
|
2
2
|
import { useEffect } from 'react';
|
|
3
|
-
import {
|
|
4
|
-
import fs from 'fs';
|
|
5
|
-
import { cleanDist } from '../../lib/execa-utils/clean.js';
|
|
6
|
-
import { webpackCompile } from '../../lib/webpack/compile.js';
|
|
3
|
+
import { buildProd } from '../../lib/build-prod.js';
|
|
7
4
|
export default function Build({ cli }) {
|
|
8
5
|
useEffect(() => {
|
|
9
|
-
async
|
|
6
|
+
(async () => {
|
|
10
7
|
const buildTarget = cli.flags.target;
|
|
11
|
-
console.log(`🚧 Building for target: ${buildTarget || 'both client and server'}`);
|
|
12
|
-
// Move node_modules/@pulse-editor/cli/dist/lib/server to node_modules/.pulse/server
|
|
13
|
-
if (buildTarget === 'server' || !buildTarget) {
|
|
14
|
-
if (fs.existsSync('node_modules/.pulse/server')) {
|
|
15
|
-
// Remove existing directory
|
|
16
|
-
if (process.platform === 'win32') {
|
|
17
|
-
await execa('rmdir /S /Q node_modules\\.pulse\\server', {
|
|
18
|
-
shell: true,
|
|
19
|
-
});
|
|
20
|
-
}
|
|
21
|
-
else {
|
|
22
|
-
await execa('rm -rf node_modules/.pulse/server', {
|
|
23
|
-
shell: true,
|
|
24
|
-
});
|
|
25
|
-
}
|
|
26
|
-
}
|
|
27
|
-
// Create node_modules/.pulse/server directory
|
|
28
|
-
if (!fs.existsSync('node_modules/.pulse/server')) {
|
|
29
|
-
if (process.platform === 'win32') {
|
|
30
|
-
await execa('mkdir node_modules\\.pulse\\server', {
|
|
31
|
-
shell: true,
|
|
32
|
-
});
|
|
33
|
-
}
|
|
34
|
-
else {
|
|
35
|
-
await execa('mkdir -p node_modules/.pulse/server', {
|
|
36
|
-
shell: true,
|
|
37
|
-
});
|
|
38
|
-
}
|
|
39
|
-
}
|
|
40
|
-
if (process.platform === 'win32') {
|
|
41
|
-
await execa('xcopy /E /I node_modules\\@pulse-editor\\cli\\dist\\lib\\server node_modules\\.pulse\\server', {
|
|
42
|
-
shell: true,
|
|
43
|
-
});
|
|
44
|
-
}
|
|
45
|
-
else {
|
|
46
|
-
await execa('cp -r node_modules/@pulse-editor/cli/dist/lib/server/* node_modules/.pulse/server/', {
|
|
47
|
-
shell: true,
|
|
48
|
-
});
|
|
49
|
-
}
|
|
50
|
-
}
|
|
51
|
-
await cleanDist();
|
|
52
8
|
try {
|
|
53
|
-
await
|
|
9
|
+
await buildProd(buildTarget);
|
|
54
10
|
}
|
|
55
11
|
catch (err) {
|
|
56
12
|
console.error('❌ Webpack build failed', err);
|
|
57
13
|
}
|
|
58
|
-
}
|
|
59
|
-
buildProd();
|
|
14
|
+
})();
|
|
60
15
|
}, []);
|
|
61
16
|
return _jsx(_Fragment, {});
|
|
62
17
|
}
|
|
@@ -6,6 +6,7 @@ import Spinner from 'ink-spinner';
|
|
|
6
6
|
import fs from 'fs';
|
|
7
7
|
import { $ } from 'execa';
|
|
8
8
|
import { publishApp } from '../../lib/backend/publish-app.js';
|
|
9
|
+
import { buildProd } from '../../lib/build-prod.js';
|
|
9
10
|
export default function Publish({ cli }) {
|
|
10
11
|
const [isInProjectDir, setIsInProjectDir] = useState(false);
|
|
11
12
|
const [isCheckingAuth, setIsCheckingAuth] = useState(true);
|
|
@@ -51,17 +52,32 @@ export default function Publish({ cli }) {
|
|
|
51
52
|
if (cli.flags.build) {
|
|
52
53
|
setIsBuilding(true);
|
|
53
54
|
try {
|
|
54
|
-
|
|
55
|
+
// Run the same in-process build pipeline as `pulse build`. We
|
|
56
|
+
// deliberately do NOT shell out to `npm run build` here — that
|
|
57
|
+
// would resolve a different `pulse` binary (project-local vs
|
|
58
|
+
// global) and potentially load a different webpack/MF tree.
|
|
59
|
+
await buildProd(cli.flags.target);
|
|
55
60
|
}
|
|
56
61
|
catch (error) {
|
|
57
62
|
setIsBuildingError(true);
|
|
58
|
-
setFailureMessage(
|
|
63
|
+
setFailureMessage(error?.stack || error?.message || String(error));
|
|
59
64
|
return;
|
|
60
65
|
}
|
|
61
66
|
finally {
|
|
62
67
|
setIsBuilding(false);
|
|
63
68
|
}
|
|
64
69
|
}
|
|
70
|
+
// Halt if the build did not actually produce a dist/ directory —
|
|
71
|
+
// this catches cases where the build script exited 0 but emitted
|
|
72
|
+
// nothing (or where --no-build was passed without a prior build).
|
|
73
|
+
if (!fs.existsSync('dist') || fs.readdirSync('dist').length === 0) {
|
|
74
|
+
setIsBuildingError(true);
|
|
75
|
+
setFailureMessage('No build output found at `dist/`. ' +
|
|
76
|
+
(cli.flags.build
|
|
77
|
+
? 'The build script completed but did not produce any output.'
|
|
78
|
+
: 'Run `pulse build` first, or omit `--no-build`.'));
|
|
79
|
+
return;
|
|
80
|
+
}
|
|
65
81
|
setIsZipping(true);
|
|
66
82
|
// Zip the dist folder
|
|
67
83
|
try {
|
|
@@ -108,5 +124,5 @@ export default function Publish({ cli }) {
|
|
|
108
124
|
buildExtension();
|
|
109
125
|
}
|
|
110
126
|
}, [isAuthenticated]);
|
|
111
|
-
return (_jsx(_Fragment, { children: !isInProjectDir ? (_jsx(Text, { color: 'redBright', children: "\u26D4 The current directory does not contain a Pulse Editor project." })) : isCheckingAuth ? (_jsxs(Box, { children: [_jsx(Spinner, { type: "dots" }), _jsx(Text, { children: " Checking authentication..." })] })) : !isAuthenticated ? (_jsxs(Text, { children: ["You are not authenticated or your access token is invalid. Publishing to Extension Marketplace is in Beta access. Please visit", _jsx(Text, { color: 'blueBright', children: " https://palmos.ai/beta " }), "to apply for Beta access."] })) : (_jsxs(_Fragment, { children: [isBuilding && (_jsxs(Box, { children: [_jsx(Spinner, { type: "dots" }), _jsx(Text, { children: " Building..." })] })), isBuildingError && (_jsx(Text, { color: 'redBright', children: "\u274C Error building the extension.
|
|
127
|
+
return (_jsx(_Fragment, { children: !isInProjectDir ? (_jsx(Text, { color: 'redBright', children: "\u26D4 The current directory does not contain a Pulse Editor project." })) : isCheckingAuth ? (_jsxs(Box, { children: [_jsx(Spinner, { type: "dots" }), _jsx(Text, { children: " Checking authentication..." })] })) : !isAuthenticated ? (_jsxs(Text, { children: ["You are not authenticated or your access token is invalid. Publishing to Extension Marketplace is in Beta access. Please visit", _jsx(Text, { color: 'blueBright', children: " https://palmos.ai/beta " }), "to apply for Beta access."] })) : (_jsxs(_Fragment, { children: [isBuilding && (_jsxs(Box, { children: [_jsx(Spinner, { type: "dots" }), _jsx(Text, { children: " Building..." })] })), isBuildingError && (_jsxs(_Fragment, { children: [_jsx(Text, { color: 'redBright', children: "\u274C Error building the extension." }), failureMessage && (_jsx(Text, { color: 'redBright', children: failureMessage }))] })), isZipping && (_jsxs(Box, { children: [_jsx(Spinner, { type: "dots" }), _jsx(Text, { children: " Compressing build..." })] })), isZippingError && (_jsxs(Text, { color: 'redBright', children: ["\u274C Error zipping the build output. ", failureMessage] })), isPublishing && (_jsxs(Box, { children: [_jsx(Spinner, { type: "dots" }), _jsx(Text, { children: " Publishing..." })] })), isPublishingError && (_jsxs(_Fragment, { children: [_jsx(Text, { color: 'redBright', children: "\u274C Failed to publish extension." }), failureMessage && (_jsxs(Text, { color: 'redBright', children: ["Error: ", failureMessage] }))] })), isPublished && (_jsx(Text, { color: 'greenBright', children: "\u2705 Extension published successfully." }))] })) }));
|
|
112
128
|
}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Run the production build pipeline in-process. Throws on failure so callers
|
|
3
|
+
* (build command, publish command) can react. This is the single source of
|
|
4
|
+
* truth for what `pulse build` does — do not duplicate this logic elsewhere.
|
|
5
|
+
*/
|
|
6
|
+
export declare function buildProd(buildTarget?: 'client' | 'server'): Promise<void>;
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
import { execa } from 'execa';
|
|
2
|
+
import fs from 'fs';
|
|
3
|
+
import { cleanDist } from './execa-utils/clean.js';
|
|
4
|
+
import { webpackCompile } from './webpack/compile.js';
|
|
5
|
+
/**
|
|
6
|
+
* Run the production build pipeline in-process. Throws on failure so callers
|
|
7
|
+
* (build command, publish command) can react. This is the single source of
|
|
8
|
+
* truth for what `pulse build` does — do not duplicate this logic elsewhere.
|
|
9
|
+
*/
|
|
10
|
+
export async function buildProd(buildTarget) {
|
|
11
|
+
console.log(`🚧 Building for target: ${buildTarget || 'both client and server'}`);
|
|
12
|
+
// Stage the server runtime under node_modules/.pulse/server so the server
|
|
13
|
+
// build has the helpers it needs at the expected path.
|
|
14
|
+
if (buildTarget === 'server' || !buildTarget) {
|
|
15
|
+
if (fs.existsSync('node_modules/.pulse/server')) {
|
|
16
|
+
if (process.platform === 'win32') {
|
|
17
|
+
await execa('rmdir /S /Q node_modules\\.pulse\\server', {
|
|
18
|
+
shell: true,
|
|
19
|
+
});
|
|
20
|
+
}
|
|
21
|
+
else {
|
|
22
|
+
await execa('rm -rf node_modules/.pulse/server', {
|
|
23
|
+
shell: true,
|
|
24
|
+
});
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
if (!fs.existsSync('node_modules/.pulse/server')) {
|
|
28
|
+
if (process.platform === 'win32') {
|
|
29
|
+
await execa('mkdir node_modules\\.pulse\\server', {
|
|
30
|
+
shell: true,
|
|
31
|
+
});
|
|
32
|
+
}
|
|
33
|
+
else {
|
|
34
|
+
await execa('mkdir -p node_modules/.pulse/server', {
|
|
35
|
+
shell: true,
|
|
36
|
+
});
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
if (process.platform === 'win32') {
|
|
40
|
+
await execa('xcopy /E /I node_modules\\@pulse-editor\\cli\\dist\\lib\\server node_modules\\.pulse\\server', { shell: true });
|
|
41
|
+
}
|
|
42
|
+
else {
|
|
43
|
+
await execa('cp -r node_modules/@pulse-editor/cli/dist/lib/server/* node_modules/.pulse/server/', { shell: true });
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
await cleanDist();
|
|
47
|
+
await webpackCompile('production', buildTarget);
|
|
48
|
+
}
|
|
@@ -49,7 +49,16 @@ export async function loadPulseConfig() {
|
|
|
49
49
|
recursive: true,
|
|
50
50
|
force: true,
|
|
51
51
|
});
|
|
52
|
-
|
|
52
|
+
const config = mod.default;
|
|
53
|
+
// Always use the version from package.json as the source of truth
|
|
54
|
+
const pkgJsonPath = path.join(projectDirName, "package.json");
|
|
55
|
+
if (existsSync(pkgJsonPath)) {
|
|
56
|
+
const pkg = JSON.parse(await fs.readFile(pkgJsonPath, "utf-8"));
|
|
57
|
+
if (pkg.version) {
|
|
58
|
+
config.version = pkg.version;
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
return config;
|
|
53
62
|
}
|
|
54
63
|
export function getLocalNetworkIP() {
|
|
55
64
|
const interfaces = networkInterfaces();
|