@fias/create-fias-plugin 1.1.3 → 1.2.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/index.js CHANGED
@@ -4,9 +4,97 @@
4
4
 
5
5
  var fs = require('fs');
6
6
  var path = require('path');
7
+ var childProcess = require('child_process');
7
8
 
8
9
  var TEMPLATE_DIR = path.resolve(__dirname, 'templates/default');
9
10
 
11
+ // =============================================================================
12
+ // Self-update on stale npx cache.
13
+ //
14
+ // Failure mode this guards against: a developer who has scaffolded a FIAS
15
+ // plugin once before has `@fias/create-fias-plugin` in their npx cache
16
+ // (`~/.npm/_npx/<hash>/`). Subsequent `npm create @fias/fias-plugin <name>`
17
+ // invocations reuse the cached binary WITHOUT checking the npm registry for
18
+ // a newer version. Result: the CLAUDE.md / AGENTS.md / templates dropped
19
+ // into their new project are months out of date, and an AI assistant
20
+ // reading those files designs against an obsolete SDK surface (we hit this
21
+ // concretely in May 2026 — a fresh scaffold's CLAUDE.md was missing the
22
+ // in-app-purchase hook, vault documents, asset library, and the
23
+ // `store:purchase` permission, even though all four had been live on npm
24
+ // for weeks).
25
+ //
26
+ // Fix: at startup, hit the registry for the latest published version. If
27
+ // our running version is older, transparently re-exec the latest via npx
28
+ // (which downloads it on the fly) with the same args, then exit. A
29
+ // `_FIAS_CREATE_REEXEC=1` env marker prevents infinite recursion when the
30
+ // freshly-installed copy starts and re-runs this same check.
31
+ //
32
+ // Any failure of the check (offline, npm slow, registry 503, ...) falls
33
+ // through silently to the cached version. Scaffolding a slightly-old
34
+ // plugin is strictly better than blocking the user on a network hiccup.
35
+ // =============================================================================
36
+
37
+ var SELF_NAME = '@fias/create-fias-plugin';
38
+ var REEXEC_GUARD = '_FIAS_CREATE_REEXEC';
39
+
40
+ function compareSemver(a, b) {
41
+ // Returns 1 if a > b, -1 if a < b, 0 if equal. Plain x.y.z; pre-release
42
+ // suffixes ignored (we never publish pre-releases of this scaffold).
43
+ var pa = a.split('.').map(function (s) {
44
+ return parseInt(s, 10) || 0;
45
+ });
46
+ var pb = b.split('.').map(function (s) {
47
+ return parseInt(s, 10) || 0;
48
+ });
49
+ for (var i = 0; i < 3; i++) {
50
+ if ((pa[i] || 0) > (pb[i] || 0)) return 1;
51
+ if ((pa[i] || 0) < (pb[i] || 0)) return -1;
52
+ }
53
+ return 0;
54
+ }
55
+
56
+ function maybeReexecLatest() {
57
+ if (process.env[REEXEC_GUARD] === '1') return;
58
+
59
+ var currentVersion = require('./package.json').version;
60
+
61
+ // 5s timeout so a slow/offline network doesn't make scaffolding hang.
62
+ var view = childProcess.spawnSync('npm', ['view', SELF_NAME, 'version'], {
63
+ encoding: 'utf-8',
64
+ timeout: 5000,
65
+ stdio: ['ignore', 'pipe', 'ignore'],
66
+ });
67
+ if (view.status !== 0 || !view.stdout) return;
68
+
69
+ var latest = view.stdout.trim();
70
+ if (!latest || compareSemver(latest, currentVersion) <= 0) return;
71
+
72
+ console.log(
73
+ '[create-fias-plugin] cached version ' +
74
+ currentVersion +
75
+ ' is stale; using latest ' +
76
+ latest +
77
+ ' from npm\n',
78
+ );
79
+
80
+ var env = Object.assign({}, process.env);
81
+ env[REEXEC_GUARD] = '1';
82
+
83
+ var rerun = childProcess.spawnSync(
84
+ 'npx',
85
+ ['--yes', SELF_NAME + '@' + latest].concat(process.argv.slice(2)),
86
+ { stdio: 'inherit', env: env },
87
+ );
88
+ process.exit(rerun.status == null ? 1 : rerun.status);
89
+ }
90
+
91
+ try {
92
+ maybeReexecLatest();
93
+ } catch (_e) {
94
+ // Any unexpected error: fall through to the cached version. Don't block
95
+ // the user on a self-update-check failure.
96
+ }
97
+
10
98
  function copyDir(src, dest, replacements, opts) {
11
99
  fs.mkdirSync(dest, { recursive: true });
12
100
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@fias/create-fias-plugin",
3
- "version": "1.1.3",
3
+ "version": "1.2.0",
4
4
  "publishConfig": {
5
5
  "access": "public"
6
6
  },
@@ -499,6 +499,7 @@ navigateTo('/settings');
499
499
 
500
500
  ### `useStepNavigation()` — Multi-step workflows
501
501
 
502
+ **Permission:** None for in-memory use; `storage:sandbox` when `persistKey` is set (it reads/writes `__state/<persistKey>` via the storage bridge).
502
503
  **Returns:** `StepNavigationApi`
503
504
 
504
505
  ```tsx
@@ -780,6 +781,44 @@ If the AI review rejects your submission, the listing-fee portion is
780
781
  refunded automatically (the per-review portion is not, since review work
781
782
  happened either way).
782
783
 
784
+ ### Managing the asset library (for `useArcheAssets`)
785
+
786
+ `useArcheAssets()` reads a contributor-curated set of images pinned to the arche's published version. Populate that library with the `assets` subcommands. Each command accepts `--env <staging|prod|local>` (default `staging`) and `--arche-id <id>` (auto-resolved from the manifest when omitted).
787
+
788
+ ```bash
789
+ npx fias-dev assets enable # Turn on the asset library for this arche
790
+ npx fias-dev assets status # Quota usage + billing summary
791
+ npx fias-dev assets upload <dir> # Bulk-upload images; subfolder name → default tag
792
+ # Flags: --concurrency <1-16>, --dry-run
793
+ npx fias-dev assets list # List assets; --tag <tag>, --limit <1-100>
794
+ npx fias-dev assets tag <assetId> --add <t> # Add or remove tags; --remove <t> also supported
795
+ npx fias-dev assets delete <assetId> # Soft-delete (excluded from future publishes); -y to skip confirm
796
+ npx fias-dev assets disable # Turn off the asset library
797
+ ```
798
+
799
+ Uploads stage into the contributor's draft set; they only become visible to plugin runtimes after the next `npm run submit` publishes a new arche version. Existing published versions keep their original frozen snapshot.
800
+
801
+ ### Managing collaborators
802
+
803
+ Multi-developer plugins use `arche_collaborators` for operational ownership (publishing, team management) — distinct from financial ownership (`contributor_id`, which is immutable in v1). Every arche must keep ≥1 active owner; revokes that would drop to zero return `MUST_KEEP_ONE_OWNER`.
804
+
805
+ ```bash
806
+ npx fias-dev collaborators list # List active collaborators
807
+ npx fias-dev collaborators add <email|username|userId> \ # Default role: publisher
808
+ --role <owner|publisher|viewer> --expires <iso> # Owners cannot have expiry
809
+ npx fias-dev collaborators set <identifier> \ # Change role and/or expiry
810
+ --role <role> --expires <iso> # --no-expires clears expiry
811
+ npx fias-dev collaborators remove <identifier> # Revoke a collaborator
812
+ ```
813
+
814
+ All commands accept `--env <staging|production|local>` (default `staging`).
815
+
816
+ ### Other CLI diagnostics
817
+
818
+ ```bash
819
+ npx fias-dev check-auth # Print per-environment auth status (which envs have saved keys)
820
+ ```
821
+
783
822
  ## Common Patterns
784
823
 
785
824
  ### Theme-Aware Card Component
@@ -499,6 +499,7 @@ navigateTo('/settings');
499
499
 
500
500
  ### `useStepNavigation()` — Multi-step workflows
501
501
 
502
+ **Permission:** None for in-memory use; `storage:sandbox` when `persistKey` is set (it reads/writes `__state/<persistKey>` via the storage bridge).
502
503
  **Returns:** `StepNavigationApi`
503
504
 
504
505
  ```tsx
@@ -780,6 +781,44 @@ If the AI review rejects your submission, the listing-fee portion is
780
781
  refunded automatically (the per-review portion is not, since review work
781
782
  happened either way).
782
783
 
784
+ ### Managing the asset library (for `useArcheAssets`)
785
+
786
+ `useArcheAssets()` reads a contributor-curated set of images pinned to the arche's published version. Populate that library with the `assets` subcommands. Each command accepts `--env <staging|prod|local>` (default `staging`) and `--arche-id <id>` (auto-resolved from the manifest when omitted).
787
+
788
+ ```bash
789
+ npx fias-dev assets enable # Turn on the asset library for this arche
790
+ npx fias-dev assets status # Quota usage + billing summary
791
+ npx fias-dev assets upload <dir> # Bulk-upload images; subfolder name → default tag
792
+ # Flags: --concurrency <1-16>, --dry-run
793
+ npx fias-dev assets list # List assets; --tag <tag>, --limit <1-100>
794
+ npx fias-dev assets tag <assetId> --add <t> # Add or remove tags; --remove <t> also supported
795
+ npx fias-dev assets delete <assetId> # Soft-delete (excluded from future publishes); -y to skip confirm
796
+ npx fias-dev assets disable # Turn off the asset library
797
+ ```
798
+
799
+ Uploads stage into the contributor's draft set; they only become visible to plugin runtimes after the next `npm run submit` publishes a new arche version. Existing published versions keep their original frozen snapshot.
800
+
801
+ ### Managing collaborators
802
+
803
+ Multi-developer plugins use `arche_collaborators` for operational ownership (publishing, team management) — distinct from financial ownership (`contributor_id`, which is immutable in v1). Every arche must keep ≥1 active owner; revokes that would drop to zero return `MUST_KEEP_ONE_OWNER`.
804
+
805
+ ```bash
806
+ npx fias-dev collaborators list # List active collaborators
807
+ npx fias-dev collaborators add <email|username|userId> \ # Default role: publisher
808
+ --role <owner|publisher|viewer> --expires <iso> # Owners cannot have expiry
809
+ npx fias-dev collaborators set <identifier> \ # Change role and/or expiry
810
+ --role <role> --expires <iso> # --no-expires clears expiry
811
+ npx fias-dev collaborators remove <identifier> # Revoke a collaborator
812
+ ```
813
+
814
+ All commands accept `--env <staging|production|local>` (default `staging`).
815
+
816
+ ### Other CLI diagnostics
817
+
818
+ ```bash
819
+ npx fias-dev check-auth # Print per-environment auth status (which envs have saved keys)
820
+ ```
821
+
783
822
  ## Common Patterns
784
823
 
785
824
  ### Theme-Aware Card Component