@doubledigit/cli 0.1.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 (89) hide show
  1. package/LICENSE +21 -0
  2. package/dist/codegen.d.ts +12 -0
  3. package/dist/codegen.d.ts.map +1 -0
  4. package/dist/codegen.js +107 -0
  5. package/dist/commands/add.d.ts +26 -0
  6. package/dist/commands/add.d.ts.map +1 -0
  7. package/dist/commands/add.js +548 -0
  8. package/dist/commands/browse.d.ts +8 -0
  9. package/dist/commands/browse.d.ts.map +1 -0
  10. package/dist/commands/browse.js +116 -0
  11. package/dist/commands/create.d.ts +12 -0
  12. package/dist/commands/create.d.ts.map +1 -0
  13. package/dist/commands/create.js +218 -0
  14. package/dist/commands/db.d.ts +2 -0
  15. package/dist/commands/db.d.ts.map +1 -0
  16. package/dist/commands/db.js +64 -0
  17. package/dist/commands/disable.d.ts +5 -0
  18. package/dist/commands/disable.d.ts.map +1 -0
  19. package/dist/commands/disable.js +29 -0
  20. package/dist/commands/doctor.d.ts +2 -0
  21. package/dist/commands/doctor.d.ts.map +1 -0
  22. package/dist/commands/doctor.js +88 -0
  23. package/dist/commands/enable.d.ts +5 -0
  24. package/dist/commands/enable.d.ts.map +1 -0
  25. package/dist/commands/enable.js +29 -0
  26. package/dist/commands/info.d.ts +8 -0
  27. package/dist/commands/info.d.ts.map +1 -0
  28. package/dist/commands/info.js +84 -0
  29. package/dist/commands/list.d.ts +5 -0
  30. package/dist/commands/list.d.ts.map +1 -0
  31. package/dist/commands/list.js +44 -0
  32. package/dist/commands/marketplace.d.ts +11 -0
  33. package/dist/commands/marketplace.d.ts.map +1 -0
  34. package/dist/commands/marketplace.js +205 -0
  35. package/dist/commands/onboard.d.ts +2 -0
  36. package/dist/commands/onboard.d.ts.map +1 -0
  37. package/dist/commands/onboard.js +58 -0
  38. package/dist/commands/outdated.d.ts +8 -0
  39. package/dist/commands/outdated.d.ts.map +1 -0
  40. package/dist/commands/outdated.js +107 -0
  41. package/dist/commands/reconcile.d.ts +12 -0
  42. package/dist/commands/reconcile.d.ts.map +1 -0
  43. package/dist/commands/reconcile.js +175 -0
  44. package/dist/commands/run.d.ts +2 -0
  45. package/dist/commands/run.d.ts.map +1 -0
  46. package/dist/commands/run.js +37 -0
  47. package/dist/commands/sync.d.ts +5 -0
  48. package/dist/commands/sync.d.ts.map +1 -0
  49. package/dist/commands/sync.js +34 -0
  50. package/dist/commands/uninstall.d.ts +14 -0
  51. package/dist/commands/uninstall.d.ts.map +1 -0
  52. package/dist/commands/uninstall.js +190 -0
  53. package/dist/config.d.ts +19 -0
  54. package/dist/config.d.ts.map +1 -0
  55. package/dist/config.js +37 -0
  56. package/dist/index.d.ts +13 -0
  57. package/dist/index.d.ts.map +1 -0
  58. package/dist/index.js +181 -0
  59. package/dist/lib/github-auth.d.ts +8 -0
  60. package/dist/lib/github-auth.d.ts.map +1 -0
  61. package/dist/lib/github-auth.js +30 -0
  62. package/dist/lib/lock-file.d.ts +67 -0
  63. package/dist/lib/lock-file.d.ts.map +1 -0
  64. package/dist/lib/lock-file.js +117 -0
  65. package/dist/lib/marketplace-schema.d.ts +607 -0
  66. package/dist/lib/marketplace-schema.d.ts.map +1 -0
  67. package/dist/lib/marketplace-schema.js +111 -0
  68. package/dist/lib/marketplace.d.ts +57 -0
  69. package/dist/lib/marketplace.d.ts.map +1 -0
  70. package/dist/lib/marketplace.js +270 -0
  71. package/dist/lib/onboarding.d.ts +84 -0
  72. package/dist/lib/onboarding.d.ts.map +1 -0
  73. package/dist/lib/onboarding.js +1004 -0
  74. package/dist/lib/rewrite-extension-tsconfig.d.ts +22 -0
  75. package/dist/lib/rewrite-extension-tsconfig.d.ts.map +1 -0
  76. package/dist/lib/rewrite-extension-tsconfig.js +80 -0
  77. package/dist/lib/source-parser.d.ts +35 -0
  78. package/dist/lib/source-parser.d.ts.map +1 -0
  79. package/dist/lib/source-parser.js +121 -0
  80. package/dist/lib/validators.d.ts +73 -0
  81. package/dist/lib/validators.d.ts.map +1 -0
  82. package/dist/lib/validators.js +435 -0
  83. package/dist/paths.d.ts +46 -0
  84. package/dist/paths.d.ts.map +1 -0
  85. package/dist/paths.js +85 -0
  86. package/dist/scanner.d.ts +41 -0
  87. package/dist/scanner.d.ts.map +1 -0
  88. package/dist/scanner.js +100 -0
  89. package/package.json +49 -0
package/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 doubledigital
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
@@ -0,0 +1,12 @@
1
+ /**
2
+ * Code generators for micro-apps.ts and payload-plugins.ts
3
+ *
4
+ * Reads the scanner output + config and generates static import files
5
+ * that the Next.js bundler can tree-shake and analyze.
6
+ */
7
+ import type { DiscoveredApp, DiscoveredPayloadPlugin } from './scanner.js';
8
+ export declare function generateMicroAppsModule(enabledApps: DiscoveredApp[]): string;
9
+ export declare function writeMicroAppsModule(outputPath: string, enabledApps: DiscoveredApp[]): void;
10
+ export declare function generatePayloadPluginsModule(plugins: DiscoveredPayloadPlugin[]): string;
11
+ export declare function writePayloadPluginsModule(outputPath: string, plugins: DiscoveredPayloadPlugin[]): void;
12
+ //# sourceMappingURL=codegen.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"codegen.d.ts","sourceRoot":"","sources":["../src/codegen.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAGH,OAAO,KAAK,EAAE,aAAa,EAAE,uBAAuB,EAAE,MAAM,cAAc,CAAC;AAQ3E,wBAAgB,uBAAuB,CACrC,WAAW,EAAE,aAAa,EAAE,GAC3B,MAAM,CAoER;AAED,wBAAgB,oBAAoB,CAClC,UAAU,EAAE,MAAM,EAClB,WAAW,EAAE,aAAa,EAAE,GAC3B,IAAI,CAIN;AAID,wBAAgB,4BAA4B,CAC1C,OAAO,EAAE,uBAAuB,EAAE,GACjC,MAAM,CAwBR;AAED,wBAAgB,yBAAyB,CACvC,UAAU,EAAE,MAAM,EAClB,OAAO,EAAE,uBAAuB,EAAE,GACjC,IAAI,CAIN"}
@@ -0,0 +1,107 @@
1
+ /**
2
+ * Code generators for micro-apps.ts and payload-plugins.ts
3
+ *
4
+ * Reads the scanner output + config and generates static import files
5
+ * that the Next.js bundler can tree-shake and analyze.
6
+ */
7
+ import fs from 'node:fs';
8
+ const HEADER = `// ⚠️ AUTO-GENERATED by @doubledigit/cli sync
9
+ // Do not edit manually. Run \`dd sync\` or \`npx @doubledigit/cli sync\` to regenerate.
10
+ //
11
+ // Generated at: {{TIMESTAMP}}
12
+ `;
13
+ export function generateMicroAppsModule(enabledApps) {
14
+ const timestamp = new Date().toISOString();
15
+ const lines = [];
16
+ // Header
17
+ lines.push(HEADER.replace('{{TIMESTAMP}}', timestamp));
18
+ // Type + config imports
19
+ lines.push("import type { DDApp } from '@doubledigit/micro-app-sdk';");
20
+ lines.push("import { isAppEnabled } from '@doubledigit/micro-app-sdk';");
21
+ lines.push("import { readDDAppsConfigFile } from './dd-apps-config';");
22
+ lines.push('');
23
+ // Static imports
24
+ if (enabledApps.length > 0) {
25
+ for (const app of enabledApps) {
26
+ lines.push(`import ${app.importName} from '${app.npmName}';`);
27
+ }
28
+ }
29
+ lines.push('');
30
+ // All micro-apps array
31
+ lines.push('// ─── All registered micro-apps (used by settings page) ───');
32
+ lines.push('export const allMicroApps: DDApp[] = [');
33
+ for (const app of enabledApps) {
34
+ lines.push(` ${app.importName},`);
35
+ }
36
+ lines.push('];');
37
+ lines.push('');
38
+ // Runtime config filtering
39
+ lines.push('// ─── Runtime config filtering ───');
40
+ lines.push('/** Enabled micro-apps only (used by shell, sidebar, routes) */');
41
+ lines.push('export const microApps: DDApp[] = [];');
42
+ lines.push('');
43
+ lines.push('// ─── Auto-derived lookup ───');
44
+ lines.push('const appMap = new Map<string, DDApp>();');
45
+ lines.push('');
46
+ lines.push('/**');
47
+ lines.push(' * Reloads the config from disk and updates the in-memory array/map in place.');
48
+ lines.push(' * This allows toggling apps enabled/disabled without restarting the Node server.');
49
+ lines.push(' */');
50
+ lines.push('export function refreshMicroAppsConfig(): void {');
51
+ lines.push(' const newConfig = readDDAppsConfigFile();');
52
+ lines.push(' const filtered = allMicroApps.filter((app) => {');
53
+ lines.push(' if (!newConfig.apps) return true;');
54
+ lines.push(' return isAppEnabled(newConfig.apps[app.key]);');
55
+ lines.push(' });');
56
+ lines.push('');
57
+ lines.push(' // Mutate in place so downstream imports see the new items');
58
+ lines.push(' microApps.length = 0;');
59
+ lines.push(' microApps.push(...filtered);');
60
+ lines.push('');
61
+ lines.push(' appMap.clear();');
62
+ lines.push(' for (const app of filtered) {');
63
+ lines.push(' appMap.set(app.key, app);');
64
+ lines.push(' }');
65
+ lines.push('}');
66
+ lines.push('');
67
+ lines.push('// Initialize on first module load');
68
+ lines.push('refreshMicroAppsConfig();');
69
+ lines.push('');
70
+ lines.push('export function loadMicroApp(key: string): DDApp | null {');
71
+ lines.push(' return appMap.get(key) ?? null;');
72
+ lines.push('}');
73
+ lines.push('');
74
+ return lines.join('\n');
75
+ }
76
+ export function writeMicroAppsModule(outputPath, enabledApps) {
77
+ const content = generateMicroAppsModule(enabledApps);
78
+ fs.mkdirSync(fs.realpathSync(outputPath + '/..'), { recursive: true });
79
+ fs.writeFileSync(outputPath, content, 'utf-8');
80
+ }
81
+ // ─── Payload Plugins codegen ───────────────────────────────────────────
82
+ export function generatePayloadPluginsModule(plugins) {
83
+ const timestamp = new Date().toISOString();
84
+ const lines = [];
85
+ lines.push(HEADER.replace('{{TIMESTAMP}}', timestamp));
86
+ lines.push("import type { Plugin } from 'payload';");
87
+ lines.push('');
88
+ if (plugins.length > 0) {
89
+ for (const plugin of plugins) {
90
+ lines.push(`import ${plugin.importName} from '${plugin.npmName}';`);
91
+ }
92
+ }
93
+ lines.push('');
94
+ lines.push('// ─── All discovered standalone payload plugins (always-on) ───');
95
+ lines.push('export const payloadPlugins: Plugin[] = [');
96
+ for (const plugin of plugins) {
97
+ lines.push(` ${plugin.importName},`);
98
+ }
99
+ lines.push('];');
100
+ lines.push('');
101
+ return lines.join('\n');
102
+ }
103
+ export function writePayloadPluginsModule(outputPath, plugins) {
104
+ const content = generatePayloadPluginsModule(plugins);
105
+ fs.mkdirSync(fs.realpathSync(outputPath + '/..'), { recursive: true });
106
+ fs.writeFileSync(outputPath, content, 'utf-8');
107
+ }
@@ -0,0 +1,26 @@
1
+ /**
2
+ * dd add <source> — Install a micro-app or payload plugin from GitHub or npm.
3
+ *
4
+ * Sources:
5
+ * gh:owner/repo/extensions/micro-apps/app GitHub micro-app subdirectory
6
+ * gh:owner/repo/extensions/micro-apps/app#v1.0.0 Specific tag/ref
7
+ * gh:owner/repo Full repo as micro-app
8
+ * github:owner/repo/path Alternative prefix
9
+ * https://github.com/owner/repo/... Full URL
10
+ * npm:@scope/package npm registry
11
+ * npm:@scope/package@1.2.3 Specific npm version
12
+ *
13
+ * Flow:
14
+ * 1. Parse source → determine type (github vs npm)
15
+ * 2. Pre-install validation
16
+ * 3. Download (giget for GitHub, pnpm for npm)
17
+ * 4. Post-download validation
18
+ * 5. Install to the appropriate extension root
19
+ * 6. Wire up (deps, TS paths, config, lock file)
20
+ * 7. Run sync + pnpm install
21
+ */
22
+ export declare function add(source: string, options?: {
23
+ name?: string;
24
+ force?: boolean;
25
+ }): Promise<void>;
26
+ //# sourceMappingURL=add.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"add.d.ts","sourceRoot":"","sources":["../../src/commands/add.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;GAoBG;AAymBH,wBAAsB,GAAG,CACvB,MAAM,EAAE,MAAM,EACd,OAAO,CAAC,EAAE;IAAE,IAAI,CAAC,EAAE,MAAM,CAAC;IAAC,KAAK,CAAC,EAAE,OAAO,CAAA;CAAE,GAC3C,OAAO,CAAC,IAAI,CAAC,CA4Ff"}