@waxhq/wax 0.2.0-alpha.1 → 0.2.0-alpha.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/README.md CHANGED
@@ -11,7 +11,7 @@ wax --help
11
11
  npx @waxhq/wax@alpha --help
12
12
  ```
13
13
 
14
- During `postinstall`, this package downloads the host `wax` binary from the matching GitHub Release, verifies its `sha256`, validates the archive shape, and exposes `wax` through npm.
14
+ During `postinstall`, this package downloads the host `wax` binary from the matching GitHub Release, verifies its `sha256`, validates the archive shape, and exposes `wax` through npm. After the binary is installed, the wrapper also runs `wax language update --all` as a best-effort refresh so any already-installed language packs can catch up to the new CLI. If the refresh cannot complete, npm install still succeeds and prints a warning instead.
15
15
 
16
16
  Supported hosts:
17
17
 
@@ -33,4 +33,4 @@ Local/test environment variables:
33
33
  - `WAX_CLI_RELEASE_BASE_URL`: override the release asset base URL, primarily for `file://` test mirrors.
34
34
  - `WAX_CLI_VERSION`: override the package version used to select release assets.
35
35
  - `WAX_CLI_REPO`: override the GitHub repository used for release downloads.
36
- - `WAX_CLI_SKIP_DOWNLOAD=1`: skip the postinstall binary download.
36
+ - `WAX_CLI_SKIP_DOWNLOAD=1`: skip the postinstall binary download and the automatic language-pack refresh.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@waxhq/wax",
3
- "version": "0.2.0-alpha.1",
3
+ "version": "0.2.0-alpha.2",
4
4
  "description": "npm wrapper for the wax design-system analysis CLI",
5
5
  "license": "MIT",
6
6
  "repository": {
package/postinstall.js CHANGED
@@ -200,6 +200,63 @@ function validateArchive(archivePath, cwd, expectedDir, expectedMember) {
200
200
  }
201
201
  }
202
202
 
203
+ function refreshInstalledLanguages(
204
+ waxPath,
205
+ {
206
+ log = console.warn,
207
+ spawnSync: runSpawnSync = spawnSync,
208
+ makeTempDir = () => fs.mkdtempSync(path.join(os.tmpdir(), "wax-cli-refresh-")),
209
+ removeTempDir = (dir) => fs.rmSync(dir, { recursive: true, force: true }),
210
+ } = {}
211
+ ) {
212
+ let neutralRepoRoot;
213
+ try {
214
+ neutralRepoRoot = makeTempDir();
215
+ } catch (error) {
216
+ log(`Warning: unable to prepare neutral repo root for language refresh after install: ${error.message}`);
217
+ return;
218
+ }
219
+
220
+ let result;
221
+ try {
222
+ result = runSpawnSync(
223
+ waxPath,
224
+ ["language", "update", "--all", "--repo-root", neutralRepoRoot],
225
+ {
226
+ cwd: neutralRepoRoot,
227
+ encoding: "utf8",
228
+ stdio: ["ignore", "pipe", "pipe"],
229
+ }
230
+ );
231
+ } finally {
232
+ try {
233
+ removeTempDir(neutralRepoRoot);
234
+ } catch (error) {
235
+ log(`Warning: unable to clean up temporary repo root after language refresh: ${error.message}`);
236
+ }
237
+ }
238
+
239
+ if (result.error) {
240
+ log(
241
+ `Warning: unable to refresh installed wax language packs after install: ${result.error.message}`
242
+ );
243
+ return;
244
+ }
245
+
246
+ if (result.status !== 0) {
247
+ const detail = (result.stderr || result.stdout || `exit status ${result.status}`).trim();
248
+ log(
249
+ `Warning: unable to refresh installed wax language packs after install: ${detail}`
250
+ );
251
+ return;
252
+ }
253
+
254
+ const output = (result.stdout || result.stderr || "").trim();
255
+ if (output) {
256
+ console.log(output);
257
+ }
258
+ }
259
+
203
260
  async function install() {
204
261
  if (process.env.WAX_CLI_SKIP_DOWNLOAD === "1") {
205
262
  console.log("Skipping wax binary download because WAX_CLI_SKIP_DOWNLOAD=1");
@@ -250,6 +307,7 @@ async function install() {
250
307
  fs.chmodSync(installPath, 0o755);
251
308
 
252
309
  console.log(`Installed wax to ${installPath}`);
310
+ refreshInstalledLanguages(installPath);
253
311
  } finally {
254
312
  fs.rmSync(tmpDir, { recursive: true, force: true });
255
313
  }
@@ -262,5 +320,6 @@ if (require.main === module) {
262
320
  module.exports = {
263
321
  download,
264
322
  expectedSha256,
323
+ refreshInstalledLanguages,
265
324
  validateArchive,
266
325
  };