ppcos 1.2.1 → 1.2.2
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/lib/commands/init-all.js +6 -3
- package/lib/commands/init.js +37 -3
- package/package.json +1 -1
package/lib/commands/init-all.js
CHANGED
|
@@ -16,7 +16,7 @@ import { fetchSkills } from '../utils/skills-fetcher.js';
|
|
|
16
16
|
import { installHubSkills } from './init.js';
|
|
17
17
|
import logger from '../utils/logger.js';
|
|
18
18
|
import ora from 'ora';
|
|
19
|
-
import { getPackageVersion,
|
|
19
|
+
import { getPackageVersion, getClientsDir } from '../utils/paths.js';
|
|
20
20
|
|
|
21
21
|
// Top-level zip entries to skip when materializing a client folder.
|
|
22
22
|
// hub-base/ is for hub-level skills; tmp/ holds runtime artifacts.
|
|
@@ -226,10 +226,13 @@ export default async function initAll(options = {}) {
|
|
|
226
226
|
}
|
|
227
227
|
}
|
|
228
228
|
|
|
229
|
-
// 4. Install hub skills if not already installed
|
|
229
|
+
// 4. Install hub skills if not already installed.
|
|
230
|
+
// Use the hub-base/ extracted from the API zip — the published npm
|
|
231
|
+
// package only ships bin/ + lib/, so getPackageRoot()/hub-base doesn't
|
|
232
|
+
// exist for normal installs.
|
|
230
233
|
const hubDir = process.cwd();
|
|
231
234
|
if (!hubManifestExists(hubDir)) {
|
|
232
|
-
const hubBasePath = join(
|
|
235
|
+
const hubBasePath = join(tempDir, 'hub-base');
|
|
233
236
|
await installHubSkills(hubBasePath);
|
|
234
237
|
}
|
|
235
238
|
|
package/lib/commands/init.js
CHANGED
|
@@ -4,9 +4,10 @@
|
|
|
4
4
|
* Usage: ppcos init <client-name> [--skip-config]
|
|
5
5
|
*/
|
|
6
6
|
|
|
7
|
-
import { existsSync, rmSync } from 'node:fs';
|
|
7
|
+
import { existsSync, mkdtempSync, rmSync } from 'node:fs';
|
|
8
8
|
import { readFile, writeFile } from 'node:fs/promises';
|
|
9
9
|
import { join } from 'node:path';
|
|
10
|
+
import { tmpdir } from 'node:os';
|
|
10
11
|
import { validateClientName } from '../utils/validation.js';
|
|
11
12
|
import { calculateChecksum } from '../utils/checksum.js';
|
|
12
13
|
import { createManifest, writeManifest, manifestExists, getManagedType, hubManifestExists, writeHubManifest } from '../utils/manifest.js';
|
|
@@ -142,9 +143,42 @@ async function createConfigTemplate() {
|
|
|
142
143
|
|
|
143
144
|
logger.success('Created main-config.json');
|
|
144
145
|
|
|
145
|
-
// Install hub skills
|
|
146
|
-
|
|
146
|
+
// Install hub skills. The published npm package ships only bin/ + lib/,
|
|
147
|
+
// so hub-base/ doesn't exist next to the installed package — we fetch
|
|
148
|
+
// the API zip into a temp dir and use its hub-base/ subdirectory. Falls
|
|
149
|
+
// back to the local hub-base/ when running from a repo checkout (dev mode).
|
|
150
|
+
const tempDir = mkdtempSync(join(tmpdir(), 'ppcos-init-hub-'));
|
|
151
|
+
let hubBasePath;
|
|
152
|
+
const spinner = ora('Downloading hub skills...').start();
|
|
153
|
+
try {
|
|
154
|
+
await fetchSkills(tempDir);
|
|
155
|
+
spinner.succeed('Hub skills downloaded');
|
|
156
|
+
hubBasePath = join(tempDir, 'hub-base');
|
|
157
|
+
} catch (err) {
|
|
158
|
+
spinner.fail('Failed to download hub skills');
|
|
159
|
+
const localHubBase = getHubBasePath();
|
|
160
|
+
if (existsSync(localHubBase)) {
|
|
161
|
+
logger.warn('Using local hub-base/ (dev mode)');
|
|
162
|
+
hubBasePath = localHubBase;
|
|
163
|
+
} else {
|
|
164
|
+
logger.error(err.message);
|
|
165
|
+
logger.error('Hub skills not installed. Run: ppcos login, then ppcos init-all');
|
|
166
|
+
rmSync(tempDir, { recursive: true, force: true });
|
|
167
|
+
printNextSteps();
|
|
168
|
+
return;
|
|
169
|
+
}
|
|
170
|
+
}
|
|
171
|
+
|
|
172
|
+
try {
|
|
173
|
+
await installHubSkills(hubBasePath);
|
|
174
|
+
} finally {
|
|
175
|
+
rmSync(tempDir, { recursive: true, force: true });
|
|
176
|
+
}
|
|
177
|
+
|
|
178
|
+
printNextSteps();
|
|
179
|
+
}
|
|
147
180
|
|
|
181
|
+
function printNextSteps() {
|
|
148
182
|
console.log('');
|
|
149
183
|
console.log('Next steps:');
|
|
150
184
|
console.log(' 1. Edit main-config.json with your client names');
|