@glassly/miniapp-cli 0.1.0 → 0.1.1-dev.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/README.md CHANGED
@@ -234,12 +234,12 @@ Required: `packageName`, `version`, `name`, `hardwareRequirements`. Everything e
234
234
 
235
235
  `port` defaults to `3000` for `dev` and is ignored by `release` (which picks its own free port). For `dev`, this is the starting port; if the port or its sidecar neighbor is busy, the CLI scans upward until it finds a free adjacent pair.
236
236
 
237
- The CLI's allowed-value lists are mirrored by hand from `@glassly/engine` and `@glassly/miniapp` to keep the tooling dependency-light so `glassly` starts fast. Drift is caught at validation time, not import time.
237
+ The allowed-value lists are read from the project's installed `@glassly/miniapp` (`@glassly/miniapp/manifest`), a peer dependency, so the validator, the schema, and the host agree by construction. A project whose SDK predates that export gets a clear upgrade message.
238
238
 
239
239
  ## File map
240
240
 
241
241
  - Command implementations (exported from `src/api.ts`, wired to subcommands by `@glassly/cli`): `src/{dev,release,pack,permission,hardware,schema,manifest-wizard}.ts`
242
- - Manifest validation + allowed-value lists: `src/manifest.ts`
242
+ - Manifest validation: `src/manifest.ts`; allowed values loaded from the SDK: `src/manifest-vocabulary.ts`
243
243
  - Manifest mutation backend (shared by wizard + object-verb commands): `src/manifest-mutate.ts`
244
244
  - Manifest read/write helpers: `src/manifest-format.ts`
245
245
  - Permission/hardware human-readable hints: `src/permission-hints.ts`
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@glassly/miniapp-cli",
3
- "version": "0.1.0",
3
+ "version": "0.1.1-dev.0",
4
4
  "description": "Build tooling for Glassly miniapps: dev server, packer, manifest validation, and JSON Schema. The `glassly` command that drives it ships in @glassly/cli.",
5
5
  "type": "module",
6
6
  "publishConfig": {
@@ -14,8 +14,7 @@
14
14
  "./package.json": "./package.json"
15
15
  },
16
16
  "scripts": {
17
- "build": "bun src/regenerate-schema.ts",
18
- "prepare": "bun src/regenerate-schema.ts"
17
+ "build": "bun src/regenerate-schema.ts"
19
18
  },
20
19
  "dependencies": {
21
20
  "@clack/prompts": "^1.2.0",
@@ -23,7 +22,11 @@
23
22
  "qrcode": "^1.5.4",
24
23
  "typescript": "^5.0.0"
25
24
  },
25
+ "peerDependencies": {
26
+ "@glassly/miniapp": ">=0.3.1-dev.528 <0.4.0"
27
+ },
26
28
  "devDependencies": {
29
+ "@glassly/miniapp": "workspace:*",
27
30
  "@types/qrcode": "^1.5.5",
28
31
  "bun-types": "1.3.14"
29
32
  },
@@ -0,0 +1,48 @@
1
+ // The allowed permission and hardware values come from the SDK the project
2
+ // builds against (`@glassly/miniapp/manifest`), so the validator, the JSON
3
+ // Schema, and the host agree by construction. The SDK is a peer dependency:
4
+ // whatever version the project installs is the one validated against.
5
+ //
6
+ // Loaded through require() rather than a static import so a project on an SDK
7
+ // that predates the export gets one clear message instead of a bare
8
+ // module-resolution error from deep inside the CLI.
9
+ import {createRequire} from 'node:module';
10
+ import type {ManifestHardwareLevel, ManifestHardwareType, ManifestPermissionType} from '@glassly/miniapp/manifest';
11
+
12
+ /** First SDK build that ships `@glassly/miniapp/manifest`. */
13
+ export const MINIMUM_SDK = '0.3.1-dev.528';
14
+
15
+ const require = createRequire(import.meta.url);
16
+
17
+ function installedSdk(): string {
18
+ try {
19
+ const version = (require('@glassly/miniapp/package.json') as {version?: string}).version;
20
+ return version ? `@glassly/miniapp@${version}` : '@glassly/miniapp (unknown version)';
21
+ } catch {
22
+ return 'no @glassly/miniapp installed';
23
+ }
24
+ }
25
+
26
+ interface ManifestModule {
27
+ MANIFEST_PERMISSION_TYPES: readonly ManifestPermissionType[];
28
+ MANIFEST_HARDWARE_TYPES: readonly ManifestHardwareType[];
29
+ MANIFEST_HARDWARE_LEVELS: readonly ManifestHardwareLevel[];
30
+ }
31
+
32
+ let loaded: ManifestModule;
33
+ try {
34
+ loaded = require('@glassly/miniapp/manifest') as ManifestModule;
35
+ } catch {
36
+ throw new Error(
37
+ `@glassly/miniapp-cli needs @glassly/miniapp ${MINIMUM_SDK} or newer (found ${installedSdk()}). ` +
38
+ `Upgrade @glassly/miniapp in your project's dependencies.`,
39
+ );
40
+ }
41
+
42
+ export const ALLOWED_PERMISSIONS: readonly ManifestPermissionType[] = loaded.MANIFEST_PERMISSION_TYPES;
43
+ export const ALLOWED_HARDWARE_TYPES: readonly ManifestHardwareType[] = loaded.MANIFEST_HARDWARE_TYPES;
44
+ export const ALLOWED_HARDWARE_LEVELS: readonly ManifestHardwareLevel[] = loaded.MANIFEST_HARDWARE_LEVELS;
45
+
46
+ export type AllowedPermission = ManifestPermissionType;
47
+ export type AllowedHardwareType = ManifestHardwareType;
48
+ export type AllowedHardwareLevel = ManifestHardwareLevel;
package/src/manifest.ts CHANGED
@@ -1,53 +1,17 @@
1
- // Note: these enum string values must stay in sync with @glassly/engine and
2
- // @glassly/miniapp. We cannot depend on them here because this lightweight CLI package
3
- // is intentionally dependency-minimal (so `bunx @glassly/miniapp-cli` starts
4
- // fast). Mirror string lists manually; failing validations point authors at
5
- // the allowed values directly.
6
- //
7
- // Sources of truth:
8
- // - AppPermissionType: mobile/modules/engine/src/types/applet.ts
9
- // - HardwareType: mobile/modules/miniapp/src/hardware.ts
10
- // - HardwareRequirementLevel: same
11
- // - AppletPermission shape: {type, required?, description?}
12
- // - HardwareRequirement shape: {type, level, description?}
13
-
14
- export const ALLOWED_PERMISSIONS = [
15
- 'MICROPHONE',
16
- 'CAMERA',
17
- 'CALENDAR',
18
- 'LOCATION',
19
- 'BACKGROUND_LOCATION',
20
- 'READ_NOTIFICATIONS',
21
- 'DISPLAY_MIRROR',
22
- 'POST_NOTIFICATIONS',
23
- 'API_KEYS',
24
- 'MEMORY',
25
- 'AI',
26
- 'SPEAKERS',
27
- 'MANAGE_MINIAPPS',
28
- 'PLATFORM_SETTINGS',
29
- ] as const;
30
-
31
- export type AllowedPermission = (typeof ALLOWED_PERMISSIONS)[number];
32
-
33
- export const ALLOWED_HARDWARE_TYPES = [
34
- 'CAMERA',
35
- 'DISPLAY',
36
- 'MICROPHONE',
37
- 'SPEAKER',
38
- 'IMU',
39
- 'BUTTON',
40
- 'LIGHT',
41
- 'WIFI',
42
- // EXIST is injected by the phone at runtime (every miniapp needs glasses
43
- // present). Do not allow authors to declare it — keep the surface minimal.
44
- ] as const;
45
-
46
- export type AllowedHardwareType = (typeof ALLOWED_HARDWARE_TYPES)[number];
47
-
48
- export const ALLOWED_HARDWARE_LEVELS = ['REQUIRED', 'OPTIONAL'] as const;
49
-
50
- export type AllowedHardwareLevel = (typeof ALLOWED_HARDWARE_LEVELS)[number];
1
+ // Allowed values come from the SDK the project builds against; see
2
+ // manifest-vocabulary.ts. Manifest shapes:
3
+ // - ManifestPermission: {type, required?, description?}
4
+ // - ManifestHardwareRequirement: {type, level, description?}
5
+ export {
6
+ ALLOWED_HARDWARE_LEVELS,
7
+ ALLOWED_HARDWARE_TYPES,
8
+ ALLOWED_PERMISSIONS,
9
+ type AllowedHardwareLevel,
10
+ type AllowedHardwareType,
11
+ type AllowedPermission,
12
+ } from './manifest-vocabulary.js';
13
+ import {ALLOWED_HARDWARE_LEVELS, ALLOWED_HARDWARE_TYPES, ALLOWED_PERMISSIONS} from './manifest-vocabulary.js';
14
+ import type {AllowedHardwareLevel, AllowedHardwareType, AllowedPermission} from './manifest-vocabulary.js';
51
15
 
52
16
  export interface ManifestPermission {
53
17
  type: AllowedPermission;
package/src/schema.ts CHANGED
@@ -1,7 +1,8 @@
1
1
  // JSON Schema generator for miniapp.json.
2
2
  //
3
3
  // The schema is built from the same constants the validator uses (ALLOWED_PERMISSIONS,
4
- // ALLOWED_HARDWARE_TYPES, ALLOWED_HARDWARE_LEVELS) so the two never drift.
4
+ // ALLOWED_HARDWARE_TYPES, ALLOWED_HARDWARE_LEVELS), which come from the installed
5
+ // @glassly/miniapp, so the schema, the validator, and the host never drift.
5
6
  //
6
7
  // Surface:
7
8
  // - generateSchema(): returns the JSON Schema object