statelyai 0.7.8 → 0.7.10

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
@@ -170,9 +170,8 @@ the credential so a later command can retry.
170
170
  | `exclude` | Globs removed from discovery. Defaults to tests and specs. |
171
171
  | `newMachinesDir` | Destination for remote-only machines created by `pull`. |
172
172
 
173
- Project-wide discovery identifies every `createMachine(...)` and
174
- `setup(...).createMachine(...)` call in configured JavaScript and TypeScript
175
- files. `push` currently supports files configured as `xstate` or `auto`.
173
+ Project-wide discovery identifies configured JavaScript and TypeScript files
174
+ that import XState and call `createMachine(...)` or `.createMachine(...)`.
176
175
 
177
176
  Mutating project commands rewrite legacy configs with one `sources` entry to
178
177
  the current top-level shape. `status` and `push --dry-run` normalize legacy
@@ -368,6 +367,9 @@ Set `NO_COLOR=1` or `CI=true` for plain output.
368
367
 
369
368
  - **The server returns `401`:** run `statelyai login`, or set
370
369
  `STATELY_ACCESS_TOKEN` or `STATELY_API_KEY`.
370
+ - **A remote command says `Not logged in`:** run `statelyai login`, then retry,
371
+ or use `statelyai init --local` for a local-only project. Add `--force` to
372
+ replace an existing config.
371
373
  - **`push` finds no files:** check `include` and `exclude`; `init` without
372
374
  `--scan` intentionally leaves `include` empty.
373
375
  - **You only need local inventory:** run `statelyai scan` or initialize with
package/dist/bin.mjs CHANGED
@@ -1,5 +1,5 @@
1
1
  #!/usr/bin/env node
2
- import { S as run } from "./cli-DicCA4VI.mjs";
2
+ import { S as run } from "./cli-Duxz6wQc.mjs";
3
3
 
4
4
  //#region src/bin.ts
5
5
  run();
@@ -1240,9 +1240,21 @@ function getSuggestionRoot(relativePath) {
1240
1240
  if (appMatch) return `apps/${appMatch[1]}/src/`;
1241
1241
  return null;
1242
1242
  }
1243
+ function getCommonDirectory(relativePaths) {
1244
+ const [firstDirectory, ...remainingDirectories] = relativePaths.map((relativePath) => path.posix.dirname(relativePath).split("/"));
1245
+ if (!firstDirectory) return;
1246
+ const commonSegments = [];
1247
+ for (const [index, segment] of firstDirectory.entries()) {
1248
+ if (!remainingDirectories.every((directory) => directory[index] === segment)) break;
1249
+ commonSegments.push(segment);
1250
+ }
1251
+ return commonSegments.length > 0 ? commonSegments.join("/") : void 0;
1252
+ }
1243
1253
  function suggestGroupedInclude(relativePaths, root) {
1244
1254
  const extPattern = formatExtensionPattern(relativePaths.map((relativePath) => path.posix.extname(relativePath)));
1245
1255
  if (relativePaths.map((relativePath) => path.posix.basename(relativePath, path.posix.extname(relativePath))).every((basename) => basename.toLowerCase().endsWith("machine"))) return `${root}**/*machine${extPattern}`;
1256
+ const commonDirectory = getCommonDirectory(relativePaths);
1257
+ if (commonDirectory) return `${commonDirectory}/${relativePaths.every((relativePath) => path.posix.dirname(relativePath) === commonDirectory) ? "*" : "**/*"}${extPattern}`;
1246
1258
  return `${root}**/*${extPattern}`;
1247
1259
  }
1248
1260
  function suggestStatelySourceConfigs(relativePaths) {
@@ -2617,16 +2629,22 @@ var InitCommand = class InitCommand extends Command {
2617
2629
  const { flags } = await this.parse(InitCommand);
2618
2630
  const resolvedApiKey = flags.local ? { source: "missing" } : await resolveApiKey();
2619
2631
  this.log(flags.local ? "Creating local project config..." : "Creating or reusing remote project...");
2620
- const result = await initProject({
2621
- apiKey: resolvedApiKey.apiKey,
2622
- baseUrl: flags["base-url"],
2623
- force: flags.force,
2624
- local: flags.local,
2625
- project: {
2626
- ...flags.name ? { name: flags.name } : {},
2627
- visibility: flags.visibility
2628
- }
2629
- });
2632
+ let result;
2633
+ try {
2634
+ result = await initProject({
2635
+ apiKey: resolvedApiKey.apiKey,
2636
+ baseUrl: flags["base-url"],
2637
+ force: flags.force,
2638
+ local: flags.local,
2639
+ project: {
2640
+ ...flags.name ? { name: flags.name } : {},
2641
+ visibility: flags.visibility
2642
+ }
2643
+ });
2644
+ } catch (error) {
2645
+ if (resolvedApiKey.source === "missing" && error instanceof StudioApiError && (error.status === 401 || error.status === 403)) this.error("Not logged in. Run `npx statelyai login` and retry. To initialize without an account, run `npx statelyai init --local` (add `--force` to replace an existing config).");
2646
+ throw error;
2647
+ }
2630
2648
  const initMessage = result.project ? (() => {
2631
2649
  const projectEditorUrl = buildProjectEditorUrl(result.config.studioUrl, result.project.projectId);
2632
2650
  return result.reusedExistingConfig ? `Using existing statelyai.json at ${result.configPath} for project ${result.project.projectId}.\nEditor: ${projectEditorUrl}` : `Initialized project ${result.project.projectId} and wrote ${result.configPath}.\nEditor: ${projectEditorUrl}`;
package/dist/index.mjs CHANGED
@@ -1,3 +1,3 @@
1
- import { C as scanProjectMachines, S as run, T as createStatelyProjectConfig, _ as isFileGitDirty, a as discoverMachinesInSource, b as resolveCredentialStatus, c as formatDiscoveredMachines, d as formatProjectStatus, f as formatStoredCredentialSource, g as initProject, h as inferInitProjectName, i as discoverLinkedPullTargets, l as formatMissingNewMachineDirMessage, m as getEnvCredential, n as buildOAuthLoginStart, o as discoverOAuthLogin, p as getEnvApiKey, r as classifyPushCandidates, s as discoverRemoteProjectMachineTargets, t as COMMANDS, u as formatPlanSummary, v as resolveApiKey, w as scanProjectSources, x as resolveProjectStatus, y as resolveConfiguredPullTargets } from "./cli-DicCA4VI.mjs";
1
+ import { C as scanProjectMachines, S as run, T as createStatelyProjectConfig, _ as isFileGitDirty, a as discoverMachinesInSource, b as resolveCredentialStatus, c as formatDiscoveredMachines, d as formatProjectStatus, f as formatStoredCredentialSource, g as initProject, h as inferInitProjectName, i as discoverLinkedPullTargets, l as formatMissingNewMachineDirMessage, m as getEnvCredential, n as buildOAuthLoginStart, o as discoverOAuthLogin, p as getEnvApiKey, r as classifyPushCandidates, s as discoverRemoteProjectMachineTargets, t as COMMANDS, u as formatPlanSummary, v as resolveApiKey, w as scanProjectSources, x as resolveProjectStatus, y as resolveConfiguredPullTargets } from "./cli-Duxz6wQc.mjs";
2
2
 
3
3
  export { COMMANDS, buildOAuthLoginStart, classifyPushCandidates, createStatelyProjectConfig, discoverLinkedPullTargets, discoverMachinesInSource, discoverOAuthLogin, discoverRemoteProjectMachineTargets, formatDiscoveredMachines, formatMissingNewMachineDirMessage, formatPlanSummary, formatProjectStatus, formatStoredCredentialSource, getEnvApiKey, getEnvCredential, inferInitProjectName, initProject, isFileGitDirty, resolveApiKey, resolveConfiguredPullTargets, resolveCredentialStatus, resolveProjectStatus, run, scanProjectMachines, scanProjectSources };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "statelyai",
3
- "version": "0.7.8",
3
+ "version": "0.7.10",
4
4
  "description": "Command-line tools for Stately",
5
5
  "license": "MIT",
6
6
  "type": "module",
@@ -21,7 +21,7 @@
21
21
  },
22
22
  "dependencies": {
23
23
  "@oclif/core": "^4.10.3",
24
- "@statelyai/sdk": "0.13.3"
24
+ "@statelyai/sdk": "0.14.0"
25
25
  },
26
26
  "devDependencies": {
27
27
  "tsdown": "0.21.0-beta.2",