@stackable-labs/cli-app-extension 1.3.0 → 1.4.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.
Files changed (2) hide show
  1. package/dist/index.js +53 -41
  2. package/package.json +2 -3
package/dist/index.js CHANGED
@@ -469,17 +469,22 @@ import Spinner2 from "ink-spinner";
469
469
  import { useEffect, useState as useState6 } from "react";
470
470
 
471
471
  // src/lib/api.ts
472
- var DEFAULT_API_URL = "https://api.stackablelabs.io/app-extension/latest";
473
472
  var DEFAULT_ADMIN_API_URL = "https://api-use1.stackablelabs.io/admin";
474
- var getApiBaseUrl = () => process.env.API_BASE_URL ?? DEFAULT_API_URL;
475
473
  var getAdminApiBaseUrl = () => process.env.ADMIN_API_BASE_URL ?? DEFAULT_ADMIN_API_URL;
476
474
  var fetchApps = async () => {
477
- const baseURL = `${getApiBaseUrl()}/apps`;
478
- const res = await fetch(baseURL);
475
+ const baseUrl = getAdminApiBaseUrl();
476
+ const res = await fetch(`${baseUrl}/app-extension`);
479
477
  if (!res.ok) {
480
- throw new Error(`Failed to fetch apps: ${res.status} ${res.statusText}`);
478
+ throw new Error(`Failed to fetch apps${baseUrl !== DEFAULT_ADMIN_API_URL ? ` (from ${baseUrl})` : ""}: ${res.status} ${res.statusText}`);
481
479
  }
482
- return res.json();
480
+ const adminApps = await res.json();
481
+ return adminApps.filter((app) => app.enabled).map(({ id, name, targets, iconUrl }) => ({
482
+ id,
483
+ name,
484
+ targets,
485
+ enabled: true,
486
+ iconUrl
487
+ }));
483
488
  };
484
489
  var createExtensionRemote = async (appId, payload) => {
485
490
  const baseUrl = getAdminApiBaseUrl();
@@ -495,12 +500,24 @@ var createExtensionRemote = async (appId, payload) => {
495
500
  return res.json();
496
501
  };
497
502
  var fetchExtensions = async (appId) => {
498
- const baseUrl = getApiBaseUrl();
499
- const res = await fetch(`${baseUrl}/extensions/${appId}`);
503
+ const baseUrl = getAdminApiBaseUrl();
504
+ const res = await fetch(`${baseUrl}/app-extension/${appId}/extensions`);
500
505
  if (!res.ok) {
501
506
  throw new Error(`Failed to fetch extensions: ${res.status} ${res.statusText}`);
502
507
  }
503
- return res.json();
508
+ const adminExtensions = await res.json();
509
+ return Object.fromEntries(
510
+ adminExtensions.filter((ext) => ext.enabled).map(({ id, manifest, bundleUrl, iconUrl }) => [
511
+ id,
512
+ {
513
+ id,
514
+ manifest,
515
+ bundleUrl,
516
+ enabled: true,
517
+ iconUrl
518
+ }
519
+ ])
520
+ );
504
521
  };
505
522
 
506
523
  // src/components/Banner.tsx
@@ -716,6 +733,8 @@ var postScaffold = async (options) => {
716
733
  import { readFile, readdir, rm, writeFile } from "fs/promises";
717
734
  import { join } from "path";
718
735
  import { downloadTemplate } from "giget";
736
+ var toKebabCase = (value) => value.trim().toLowerCase().replace(/[^a-z0-9]+/g, "-").replace(/^-+|-+$/g, "");
737
+ var isTextFile = (filePath) => /\.(ts|tsx|js|jsx|json|md|html|yml|yaml|env|gitignore|nvmrc)$/i.test(filePath);
719
738
  var normalizeTargets = (targets) => Array.from(new Set(targets));
720
739
  var derivePermissions = (targets) => {
721
740
  const permissions = /* @__PURE__ */ new Set();
@@ -731,7 +750,29 @@ var derivePermissions = (targets) => {
731
750
  }
732
751
  return [...permissions];
733
752
  };
734
- var toKebabCase = (value) => value.trim().toLowerCase().replace(/[^a-z0-9]+/g, "-").replace(/^-+|-+$/g, "");
753
+ var upsertOrRemove = async (filePath, shouldExist, content) => {
754
+ if (shouldExist) {
755
+ await writeFile(filePath, content);
756
+ return;
757
+ }
758
+ await rm(filePath, { force: true });
759
+ };
760
+ var walkFiles = async (rootDir) => {
761
+ const entries = await readdir(rootDir, { withFileTypes: true });
762
+ const files = [];
763
+ for (const entry of entries) {
764
+ if (entry.name === ".git" || entry.name === "node_modules" || entry.name === "dist") {
765
+ continue;
766
+ }
767
+ const fullPath = join(rootDir, entry.name);
768
+ if (entry.isDirectory()) {
769
+ files.push(...await walkFiles(fullPath));
770
+ continue;
771
+ }
772
+ files.push(fullPath);
773
+ }
774
+ return files;
775
+ };
735
776
  var replacePlaceholders = async (rootDir, replacements) => {
736
777
  const files = await walkFiles(rootDir);
737
778
  for (const filePath of files) {
@@ -960,23 +1001,6 @@ var rewriteTurboJson = async (rootDir) => {
960
1001
  await writeFile(turboPath, `${JSON.stringify(turbo, null, 2)}
961
1002
  `);
962
1003
  };
963
- var walkFiles = async (rootDir) => {
964
- const entries = await readdir(rootDir, { withFileTypes: true });
965
- const files = [];
966
- for (const entry of entries) {
967
- if (entry.name === ".git" || entry.name === "node_modules" || entry.name === "dist") {
968
- continue;
969
- }
970
- const fullPath = join(rootDir, entry.name);
971
- if (entry.isDirectory()) {
972
- files.push(...await walkFiles(fullPath));
973
- continue;
974
- }
975
- files.push(fullPath);
976
- }
977
- return files;
978
- };
979
- var isTextFile = (filePath) => /\.(ts|tsx|js|jsx|json|md|html|yml|yaml|env|gitignore|nvmrc)$/i.test(filePath);
980
1004
  var writeEnvFile = async (dir, extensionPort, previewPort) => {
981
1005
  const envPath = join(dir, ".env");
982
1006
  const content = `VITE_EXTENSION_PORT=${extensionPort}
@@ -984,13 +1008,6 @@ VITE_PREVIEW_PORT=${previewPort}
984
1008
  `;
985
1009
  await writeFile(envPath, content);
986
1010
  };
987
- var upsertOrRemove = async (filePath, shouldExist, content) => {
988
- if (shouldExist) {
989
- await writeFile(filePath, content);
990
- return;
991
- }
992
- await rm(filePath, { force: true });
993
- };
994
1011
  var scaffold = async (options) => {
995
1012
  const { dir } = await downloadTemplate(TEMPLATE_SOURCE, {
996
1013
  dir: options.outputDir,
@@ -1269,16 +1286,11 @@ var App = ({ command, initialName, options }) => {
1269
1286
 
1270
1287
  // src/index.tsx
1271
1288
  import { jsx as jsx13 } from "react/jsx-runtime";
1272
- program.name("stackable-extension").description("Stackable extension developer CLI");
1289
+ program.name("stackable-app-extension").description("Stackable app extension developer CLI");
1273
1290
  program.command("create" /* CREATE */).description("Create a new Extension project").argument("[name]", "Extension project name").option("--extension-port <port>", "Extension dev server port (default: 5173)").option("--preview-port <port>", "Preview host dev server port").option("--skip-install", "Skip package manager install").option("--skip-git", "Skip git initialization").action((name, options) => {
1274
1291
  render(/* @__PURE__ */ jsx13(App, { command: "create" /* CREATE */, initialName: name, options }));
1275
1292
  });
1276
1293
  program.command("scaffold" /* SCAFFOLD */).description("Scaffold a local project from an existing Extension").option("--extension-port <port>", "Extension dev server port (default: 5173)").option("--preview-port <port>", "Preview host dev server port").option("--skip-install", "Skip package manager install").option("--skip-git", "Skip git initialization").action((options) => {
1277
1294
  render(/* @__PURE__ */ jsx13(App, { command: "scaffold" /* SCAFFOLD */, options }));
1278
1295
  });
1279
- if (process.argv[1]?.endsWith("create-extension")) {
1280
- process.stderr.write("\u26A0\uFE0F DEPRECATED: `create-extension` is deprecated and will be removed in v2.0.0. Use `stackable-extension create` instead.\n");
1281
- program.parse(["node", "stackable-extension", "create", ...process.argv.slice(2).filter((arg) => arg !== "--")]);
1282
- } else {
1283
- program.parse(process.argv.filter((arg) => arg !== "--"));
1284
- }
1296
+ program.parse(process.argv.filter((arg) => arg !== "--"));
package/package.json CHANGED
@@ -1,11 +1,10 @@
1
1
  {
2
2
  "name": "@stackable-labs/cli-app-extension",
3
- "version": "1.3.0",
3
+ "version": "1.4.0",
4
4
  "type": "module",
5
5
  "private": false,
6
6
  "bin": {
7
- "create-extension": "./dist/index.js",
8
- "stackable-extension": "./dist/index.js"
7
+ "stackable-app-extension": "./dist/index.js"
9
8
  },
10
9
  "files": [
11
10
  "dist/",