@sentientui/cli 0.2.4 → 0.2.6

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/dist/index.cjs CHANGED
@@ -4,22 +4,8 @@ var __create = Object.create;
4
4
  var __defProp = Object.defineProperty;
5
5
  var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
6
6
  var __getOwnPropNames = Object.getOwnPropertyNames;
7
- var __getOwnPropSymbols = Object.getOwnPropertySymbols;
8
7
  var __getProtoOf = Object.getPrototypeOf;
9
8
  var __hasOwnProp = Object.prototype.hasOwnProperty;
10
- var __propIsEnum = Object.prototype.propertyIsEnumerable;
11
- var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
12
- var __spreadValues = (a, b) => {
13
- for (var prop in b || (b = {}))
14
- if (__hasOwnProp.call(b, prop))
15
- __defNormalProp(a, prop, b[prop]);
16
- if (__getOwnPropSymbols)
17
- for (var prop of __getOwnPropSymbols(b)) {
18
- if (__propIsEnum.call(b, prop))
19
- __defNormalProp(a, prop, b[prop]);
20
- }
21
- return a;
22
- };
23
9
  var __export = (target, all) => {
24
10
  for (var name in all)
25
11
  __defProp(target, name, { get: all[name], enumerable: true });
@@ -49,12 +35,6 @@ __export(index_exports, {
49
35
  parseArgs: () => parseArgs
50
36
  });
51
37
  module.exports = __toCommonJS(index_exports);
52
-
53
- // ../../node_modules/.pnpm/tsup@8.5.1_jiti@1.21.7_postcss@8.5.14_tsx@4.22.1_typescript@5.9.3_yaml@2.9.0/node_modules/tsup/assets/cjs_shims.js
54
- var getImportMetaUrl = () => typeof document === "undefined" ? new URL(`file:${__filename}`).href : document.currentScript && document.currentScript.tagName.toUpperCase() === "SCRIPT" ? document.currentScript.src : new URL("main.js", document.baseURI).href;
55
- var importMetaUrl = /* @__PURE__ */ getImportMetaUrl();
56
-
57
- // src/index.ts
58
38
  var import_node_fs4 = require("fs");
59
39
  var import_node_url = require("url");
60
40
 
@@ -67,14 +47,14 @@ var import_node_path = __toESM(require("path"), 1);
67
47
  function readPackageJson(cwd) {
68
48
  try {
69
49
  return JSON.parse((0, import_node_fs.readFileSync)(import_node_path.default.join(cwd, "package.json"), "utf-8"));
70
- } catch (e) {
50
+ } catch {
71
51
  return null;
72
52
  }
73
53
  }
74
54
  function detectFramework(cwd) {
75
55
  const pkg = readPackageJson(cwd);
76
56
  if (!pkg) return "unknown";
77
- const deps = __spreadValues(__spreadValues({}, pkg.dependencies), pkg.devDependencies);
57
+ const deps = { ...pkg.dependencies, ...pkg.devDependencies };
78
58
  const has = (dir) => (0, import_node_fs.existsSync)(import_node_path.default.join(cwd, dir));
79
59
  if (deps["next"]) {
80
60
  if (has("app") || has(import_node_path.default.join("src", "app"))) return "next-app";
@@ -127,7 +107,7 @@ function writeEnvFile(cwd, framework, key) {
127
107
  const block = [
128
108
  "",
129
109
  "# SentientUI \u2014 leave empty for local mode (decisions are simulated on-device; nothing is sent)",
130
- `${varName}=${key != null ? key : ""}`,
110
+ `${varName}=${key ?? ""}`,
131
111
  ""
132
112
  ].join("\n");
133
113
  if (!(0, import_node_fs2.existsSync)(file)) {
@@ -135,7 +115,7 @@ function writeEnvFile(cwd, framework, key) {
135
115
  return "created";
136
116
  }
137
117
  const existing = (0, import_node_fs2.readFileSync)(file, "utf-8");
138
- const assigned = existing.split(/\r?\n/).some((line) => line.trim().startsWith(`${varName}=`));
118
+ const assigned = existing.split(/\r?\n/).some((line) => line.trim().replace(/^#+\s*/, "").startsWith(`${varName}=`));
139
119
  if (assigned) return "kept";
140
120
  (0, import_node_fs2.appendFileSync)(file, block, "utf-8");
141
121
  return "appended";
@@ -287,13 +267,19 @@ function warnIfNotPublishableKey(key, log = (line) => console.warn(line)) {
287
267
  log("");
288
268
  return true;
289
269
  }
270
+ function assertPublishableKey(key, log = (line) => console.error(line)) {
271
+ if (warnIfNotPublishableKey(key, log)) {
272
+ throw new Error(
273
+ "Refusing to write a non-publishable key into a client-exposed env var. Only publishable pk_ keys belong in the browser bundle \u2014 pass your pk_ key from the SentientUI dashboard, or omit --key for local mode."
274
+ );
275
+ }
276
+ }
290
277
 
291
278
  // src/init.ts
292
279
  function runInit(opts) {
293
- var _a, _b, _c;
294
- const log = (_a = opts.log) != null ? _a : ((line) => console.log(line));
295
- const exec = (_b = opts.exec) != null ? _b : ((command, cwd) => (0, import_node_child_process.execSync)(command, { cwd, stdio: "inherit" }));
296
- warnIfNotPublishableKey(opts.key, log);
280
+ const log = opts.log ?? ((line) => console.log(line));
281
+ const exec = opts.exec ?? ((command, cwd) => (0, import_node_child_process.execSync)(command, { cwd, stdio: "inherit" }));
282
+ assertPublishableKey(opts.key, log);
297
283
  const framework = detectFramework(opts.cwd);
298
284
  log(`[sentientui] detected framework: ${framework}`);
299
285
  if (framework === "unknown") {
@@ -306,7 +292,7 @@ function runInit(opts) {
306
292
  exec(install, opts.cwd);
307
293
  const envResult = writeEnvFile(opts.cwd, framework, opts.key);
308
294
  log(
309
- `[sentientui] .env.local ${envResult}: ${envVarName(framework)}=${(_c = opts.key) != null ? _c : "(empty \u2014 local mode)"}`
295
+ `[sentientui] .env.local ${envResult}: ${envVarName(framework)}=${opts.key ?? "(empty \u2014 local mode)"}`
310
296
  );
311
297
  const scaffolded = scaffoldExample(opts.cwd);
312
298
  log(
@@ -321,6 +307,7 @@ function runInit(opts) {
321
307
  }
322
308
 
323
309
  // src/index.ts
310
+ var import_meta = {};
324
311
  function parseArgs(argv) {
325
312
  const args = [...argv];
326
313
  const command = args.shift();
@@ -354,8 +341,8 @@ function isRunAsScript() {
354
341
  try {
355
342
  const entry = process.argv[1];
356
343
  if (!entry) return false;
357
- return (0, import_node_fs4.realpathSync)((0, import_node_url.fileURLToPath)(importMetaUrl)) === (0, import_node_fs4.realpathSync)(entry);
358
- } catch (e) {
344
+ return (0, import_node_fs4.realpathSync)((0, import_node_url.fileURLToPath)(import_meta.url)) === (0, import_node_fs4.realpathSync)(entry);
345
+ } catch {
359
346
  return false;
360
347
  }
361
348
  }
package/dist/index.js CHANGED
@@ -1,20 +1,4 @@
1
1
  #!/usr/bin/env node
2
- var __defProp = Object.defineProperty;
3
- var __getOwnPropSymbols = Object.getOwnPropertySymbols;
4
- var __hasOwnProp = Object.prototype.hasOwnProperty;
5
- var __propIsEnum = Object.prototype.propertyIsEnumerable;
6
- var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
7
- var __spreadValues = (a, b) => {
8
- for (var prop in b || (b = {}))
9
- if (__hasOwnProp.call(b, prop))
10
- __defNormalProp(a, prop, b[prop]);
11
- if (__getOwnPropSymbols)
12
- for (var prop of __getOwnPropSymbols(b)) {
13
- if (__propIsEnum.call(b, prop))
14
- __defNormalProp(a, prop, b[prop]);
15
- }
16
- return a;
17
- };
18
2
 
19
3
  // src/index.ts
20
4
  import { realpathSync } from "fs";
@@ -29,14 +13,14 @@ import path from "path";
29
13
  function readPackageJson(cwd) {
30
14
  try {
31
15
  return JSON.parse(readFileSync(path.join(cwd, "package.json"), "utf-8"));
32
- } catch (e) {
16
+ } catch {
33
17
  return null;
34
18
  }
35
19
  }
36
20
  function detectFramework(cwd) {
37
21
  const pkg = readPackageJson(cwd);
38
22
  if (!pkg) return "unknown";
39
- const deps = __spreadValues(__spreadValues({}, pkg.dependencies), pkg.devDependencies);
23
+ const deps = { ...pkg.dependencies, ...pkg.devDependencies };
40
24
  const has = (dir) => existsSync(path.join(cwd, dir));
41
25
  if (deps["next"]) {
42
26
  if (has("app") || has(path.join("src", "app"))) return "next-app";
@@ -89,7 +73,7 @@ function writeEnvFile(cwd, framework, key) {
89
73
  const block = [
90
74
  "",
91
75
  "# SentientUI \u2014 leave empty for local mode (decisions are simulated on-device; nothing is sent)",
92
- `${varName}=${key != null ? key : ""}`,
76
+ `${varName}=${key ?? ""}`,
93
77
  ""
94
78
  ].join("\n");
95
79
  if (!existsSync2(file)) {
@@ -97,7 +81,7 @@ function writeEnvFile(cwd, framework, key) {
97
81
  return "created";
98
82
  }
99
83
  const existing = readFileSync2(file, "utf-8");
100
- const assigned = existing.split(/\r?\n/).some((line) => line.trim().startsWith(`${varName}=`));
84
+ const assigned = existing.split(/\r?\n/).some((line) => line.trim().replace(/^#+\s*/, "").startsWith(`${varName}=`));
101
85
  if (assigned) return "kept";
102
86
  appendFileSync(file, block, "utf-8");
103
87
  return "appended";
@@ -249,13 +233,19 @@ function warnIfNotPublishableKey(key, log = (line) => console.warn(line)) {
249
233
  log("");
250
234
  return true;
251
235
  }
236
+ function assertPublishableKey(key, log = (line) => console.error(line)) {
237
+ if (warnIfNotPublishableKey(key, log)) {
238
+ throw new Error(
239
+ "Refusing to write a non-publishable key into a client-exposed env var. Only publishable pk_ keys belong in the browser bundle \u2014 pass your pk_ key from the SentientUI dashboard, or omit --key for local mode."
240
+ );
241
+ }
242
+ }
252
243
 
253
244
  // src/init.ts
254
245
  function runInit(opts) {
255
- var _a, _b, _c;
256
- const log = (_a = opts.log) != null ? _a : ((line) => console.log(line));
257
- const exec = (_b = opts.exec) != null ? _b : ((command, cwd) => execSync(command, { cwd, stdio: "inherit" }));
258
- warnIfNotPublishableKey(opts.key, log);
246
+ const log = opts.log ?? ((line) => console.log(line));
247
+ const exec = opts.exec ?? ((command, cwd) => execSync(command, { cwd, stdio: "inherit" }));
248
+ assertPublishableKey(opts.key, log);
259
249
  const framework = detectFramework(opts.cwd);
260
250
  log(`[sentientui] detected framework: ${framework}`);
261
251
  if (framework === "unknown") {
@@ -268,7 +258,7 @@ function runInit(opts) {
268
258
  exec(install, opts.cwd);
269
259
  const envResult = writeEnvFile(opts.cwd, framework, opts.key);
270
260
  log(
271
- `[sentientui] .env.local ${envResult}: ${envVarName(framework)}=${(_c = opts.key) != null ? _c : "(empty \u2014 local mode)"}`
261
+ `[sentientui] .env.local ${envResult}: ${envVarName(framework)}=${opts.key ?? "(empty \u2014 local mode)"}`
272
262
  );
273
263
  const scaffolded = scaffoldExample(opts.cwd);
274
264
  log(
@@ -283,7 +273,6 @@ function runInit(opts) {
283
273
  }
284
274
 
285
275
  // src/index.ts
286
- var import_meta = {};
287
276
  function parseArgs(argv) {
288
277
  const args = [...argv];
289
278
  const command = args.shift();
@@ -317,8 +306,8 @@ function isRunAsScript() {
317
306
  try {
318
307
  const entry = process.argv[1];
319
308
  if (!entry) return false;
320
- return realpathSync(fileURLToPath(import_meta.url)) === realpathSync(entry);
321
- } catch (e) {
309
+ return realpathSync(fileURLToPath(import.meta.url)) === realpathSync(entry);
310
+ } catch {
322
311
  return false;
323
312
  }
324
313
  }
package/package.json CHANGED
@@ -1,14 +1,15 @@
1
1
  {
2
2
  "name": "@sentientui/cli",
3
- "version": "0.2.4",
3
+ "version": "0.2.6",
4
4
  "description": "SentientUI CLI — `npx @sentientui/cli init` sets up adaptive UI in an existing React app (installs the SDK, writes env config, scaffolds an example, and prints the wrap instructions)",
5
5
  "license": "MIT",
6
6
  "homepage": "https://sentient-ui.com",
7
7
  "repository": {
8
8
  "type": "git",
9
- "url": "git+https://github.com/casancam/SentientUI.git",
9
+ "url": "git+https://github.com/SentientUI/sdk.git",
10
10
  "directory": "packages/cli"
11
11
  },
12
+ "bugs": "https://github.com/SentientUI/sdk/issues",
12
13
  "keywords": [
13
14
  "cli",
14
15
  "sentientui",