@cipherstash/stack 0.9.0 → 0.10.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/CHANGELOG.md CHANGED
@@ -1,5 +1,11 @@
1
1
  # @cipherstash/stack
2
2
 
3
+ ## 0.10.0
4
+
5
+ ### Minor Changes
6
+
7
+ - 5245cd7: Improved CLI setup and initialization commands.
8
+
3
9
  ## 0.9.0
4
10
 
5
11
  ### Minor Changes
package/dist/bin/stash.js CHANGED
@@ -1295,6 +1295,18 @@ function detectPackageManager() {
1295
1295
  if (existsSync(resolve(cwd, "yarn.lock"))) return "yarn";
1296
1296
  return "npm";
1297
1297
  }
1298
+ function prodInstallCommand(pm, packageName) {
1299
+ switch (pm) {
1300
+ case "bun":
1301
+ return `bun add ${packageName}`;
1302
+ case "pnpm":
1303
+ return `pnpm add ${packageName}`;
1304
+ case "yarn":
1305
+ return `yarn add ${packageName}`;
1306
+ case "npm":
1307
+ return `npm install ${packageName}`;
1308
+ }
1309
+ }
1298
1310
  function devInstallCommand(pm, packageName) {
1299
1311
  switch (pm) {
1300
1312
  case "bun":
@@ -1568,44 +1580,50 @@ var buildSchemaStep = {
1568
1580
 
1569
1581
  // src/bin/commands/init/steps/install-forge.ts
1570
1582
  import { execSync } from "node:child_process";
1583
+ var STACK_PACKAGE = "@cipherstash/stack";
1571
1584
  var FORGE_PACKAGE = "@cipherstash/stack-forge";
1585
+ async function installIfNeeded(packageName, buildCommand, depLabel) {
1586
+ if (isPackageInstalled(packageName)) {
1587
+ M2.success(`${packageName} is already installed.`);
1588
+ return true;
1589
+ }
1590
+ const pm = detectPackageManager();
1591
+ const cmd = buildCommand(pm, packageName);
1592
+ const install = await ye({
1593
+ message: `Install ${packageName} as a ${depLabel} dependency? (${cmd})`
1594
+ });
1595
+ if (pD(install)) throw new CancelledError();
1596
+ if (!install) {
1597
+ M2.info(`Skipping ${packageName} installation.`);
1598
+ Me(
1599
+ `You can install it manually later:
1600
+ ${cmd}`,
1601
+ "Manual Installation"
1602
+ );
1603
+ return false;
1604
+ }
1605
+ const s = Y2();
1606
+ s.start(`Installing ${packageName}...`);
1607
+ try {
1608
+ execSync(cmd, { cwd: process.cwd(), stdio: "pipe" });
1609
+ s.stop(`${packageName} installed successfully`);
1610
+ return true;
1611
+ } catch (err) {
1612
+ const message = err instanceof Error ? err.message : String(err);
1613
+ s.stop(`${packageName} installation failed`);
1614
+ M2.error(message);
1615
+ Me(`You can install it manually:
1616
+ ${cmd}`, "Manual Installation");
1617
+ return false;
1618
+ }
1619
+ }
1572
1620
  var installForgeStep = {
1573
1621
  id: "install-forge",
1574
- name: "Install stack-forge",
1622
+ name: "Install stack dependencies",
1575
1623
  async run(state, _provider) {
1576
- if (isPackageInstalled(FORGE_PACKAGE)) {
1577
- M2.success(`${FORGE_PACKAGE} is already installed.`);
1578
- return { ...state, forgeInstalled: true };
1579
- }
1580
- const pm = detectPackageManager();
1581
- const cmd = devInstallCommand(pm, FORGE_PACKAGE);
1582
- const install = await ye({
1583
- message: `Install ${FORGE_PACKAGE} as a dev dependency? (${cmd})`
1584
- });
1585
- if (pD(install)) throw new CancelledError();
1586
- if (!install) {
1587
- M2.info(`Skipping ${FORGE_PACKAGE} installation.`);
1588
- Me(
1589
- `You can install it manually later:
1590
- ${cmd}`,
1591
- "Manual Installation"
1592
- );
1593
- return { ...state, forgeInstalled: false };
1594
- }
1595
- const s = Y2();
1596
- s.start(`Installing ${FORGE_PACKAGE}...`);
1597
- try {
1598
- execSync(cmd, { cwd: process.cwd(), stdio: "pipe" });
1599
- s.stop(`${FORGE_PACKAGE} installed successfully`);
1600
- return { ...state, forgeInstalled: true };
1601
- } catch (err) {
1602
- const message = err instanceof Error ? err.message : String(err);
1603
- s.stop(`${FORGE_PACKAGE} installation failed`);
1604
- M2.error(message);
1605
- Me(`You can install it manually:
1606
- ${cmd}`, "Manual Installation");
1607
- return { ...state, forgeInstalled: false };
1608
- }
1624
+ const stackInstalled = await installIfNeeded(STACK_PACKAGE, prodInstallCommand, "production");
1625
+ const forgeInstalled = await installIfNeeded(FORGE_PACKAGE, devInstallCommand, "dev");
1626
+ return { ...state, forgeInstalled, stackInstalled };
1609
1627
  }
1610
1628
  };
1611
1629