@doubledigit/cli 0.3.0 → 0.3.2
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
|
@@ -118,7 +118,17 @@ dd actions remotion-hub
|
|
|
118
118
|
dd actions remotion-hub search-components --query "animated chart" --limit 5
|
|
119
119
|
```
|
|
120
120
|
|
|
121
|
-
The command resolves the app URL from `DD_APP_URL`, `APP_URL`, or `
|
|
121
|
+
The command resolves the app URL from `DD_APP_URL`, `APP_URL`, `BETTER_AUTH_URL`, or `http://localhost:3111` and prints JSON responses to stdout. It also reads `.env`, `.env.local`, `apps/main-app/.env`, and `apps/main-app/.env.local`; exported shell values take precedence.
|
|
122
|
+
|
|
123
|
+
Local development should use the local app URL. Use `DD_APP_URL` only when the action should intentionally hit a deployed app:
|
|
124
|
+
|
|
125
|
+
```bash
|
|
126
|
+
DD_APP_URL=https://your-project.vercel.app dd actions remotion-hub
|
|
127
|
+
```
|
|
128
|
+
|
|
129
|
+
In GitHub Actions or another CI/CD runner, provide `DD_APP_URL` through the runner environment, variables, or secrets. Do not rely on a local env file being present in CI, and do not point local `.env` files at Vercel by default.
|
|
130
|
+
|
|
131
|
+
GitHub or Infisical secrets are CI/CD inputs only. A local `npx @doubledigit/cli ...` command sees your shell environment and local env files, not repository secrets.
|
|
122
132
|
|
|
123
133
|
## Links
|
|
124
134
|
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"actions.d.ts","sourceRoot":"","sources":["../../src/commands/actions.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"actions.d.ts","sourceRoot":"","sources":["../../src/commands/actions.ts"],"names":[],"mappings":"AAiEA,wBAAsB,OAAO,CAAC,IAAI,EAAE,MAAM,EAAE,GAAG,OAAO,CAAC,IAAI,CAAC,CAqB3D"}
|
package/dist/commands/actions.js
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
|
+
import path from 'node:path';
|
|
1
2
|
import { readConfig, isEntryEnabled } from '../config.js';
|
|
2
|
-
import { DEFAULT_APP_URL } from '../lib/onboarding.js';
|
|
3
|
-
import { buildActionRequest, fetchActionRequest, parseActionsArgs, } from '../lib/actions-client.js';
|
|
3
|
+
import { DEFAULT_APP_URL, readEnvFile } from '../lib/onboarding.js';
|
|
4
|
+
import { buildActionRequest, fetchActionRequest, parseActionsArgs, resolveActionAppUrl, } from '../lib/actions-client.js';
|
|
4
5
|
import { resolveWorkspacePaths } from '../paths.js';
|
|
5
6
|
import { scanWorkspace } from '../scanner.js';
|
|
6
7
|
const HELP = `
|
|
@@ -11,7 +12,7 @@ Usage:
|
|
|
11
12
|
dd actions <micro-app> <action> [options]
|
|
12
13
|
|
|
13
14
|
Options:
|
|
14
|
-
--url, --app-url <url> App URL (default: DD_APP_URL, APP_URL, or ${DEFAULT_APP_URL})
|
|
15
|
+
--url, --app-url <url> App URL (default: DD_APP_URL, APP_URL, BETTER_AUTH_URL, or ${DEFAULT_APP_URL})
|
|
15
16
|
--json <json> JSON request body to send to the action
|
|
16
17
|
--query <text> Set input.query
|
|
17
18
|
--limit <number> Set input.limit
|
|
@@ -28,15 +29,19 @@ Examples:
|
|
|
28
29
|
dd actions remotion-hub get-component --namespace doubledigit --slug motion-strip
|
|
29
30
|
dd actions remotion-hub get-registry-payload --json '{"namespace":"doubledigit","slug":"motion-strip"}'
|
|
30
31
|
`;
|
|
31
|
-
function
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
32
|
+
function readActionEnvFiles(paths) {
|
|
33
|
+
const env = {};
|
|
34
|
+
for (const envPath of [
|
|
35
|
+
path.join(paths.root, '.env'),
|
|
36
|
+
path.join(paths.mainAppDir, '.env'),
|
|
37
|
+
path.join(paths.root, '.env.local'),
|
|
38
|
+
path.join(paths.mainAppDir, '.env.local'),
|
|
39
|
+
]) {
|
|
40
|
+
Object.assign(env, readEnvFile(envPath));
|
|
41
|
+
}
|
|
42
|
+
return env;
|
|
37
43
|
}
|
|
38
|
-
function validateMicroApp(microApp) {
|
|
39
|
-
const paths = resolveWorkspacePaths();
|
|
44
|
+
function validateMicroApp(paths, microApp) {
|
|
40
45
|
const app = scanWorkspace(paths).microApps.find((candidate) => candidate.key === microApp);
|
|
41
46
|
if (!app) {
|
|
42
47
|
throw new Error(`Unknown micro-app: ${microApp}`);
|
|
@@ -52,8 +57,13 @@ export async function actions(args) {
|
|
|
52
57
|
console.log(HELP);
|
|
53
58
|
return;
|
|
54
59
|
}
|
|
55
|
-
|
|
56
|
-
|
|
60
|
+
const paths = resolveWorkspacePaths();
|
|
61
|
+
validateMicroApp(paths, parsed.microApp);
|
|
62
|
+
const request = buildActionRequest(parsed, resolveActionAppUrl({
|
|
63
|
+
explicitUrl: parsed.appUrl,
|
|
64
|
+
fileEnv: readActionEnvFiles(paths),
|
|
65
|
+
defaultUrl: DEFAULT_APP_URL,
|
|
66
|
+
}));
|
|
57
67
|
const result = await fetchActionRequest(request);
|
|
58
68
|
console.log(JSON.stringify(result, null, 2));
|
|
59
69
|
}
|
|
@@ -9,6 +9,13 @@ export interface ActionRequest {
|
|
|
9
9
|
url: string;
|
|
10
10
|
init: RequestInit;
|
|
11
11
|
}
|
|
12
|
+
export interface ResolveActionAppUrlOptions {
|
|
13
|
+
explicitUrl?: string;
|
|
14
|
+
env?: Record<string, string | undefined>;
|
|
15
|
+
fileEnv?: Record<string, string | undefined>;
|
|
16
|
+
defaultUrl: string;
|
|
17
|
+
}
|
|
18
|
+
export declare function resolveActionAppUrl({ explicitUrl, env, fileEnv, defaultUrl, }: ResolveActionAppUrlOptions): string;
|
|
12
19
|
export declare function parseActionsArgs(args: string[]): ParsedActionsArgs;
|
|
13
20
|
export declare function normalizeAppUrl(appUrl: string): string;
|
|
14
21
|
export declare function buildActionRequest(parsed: Pick<ParsedActionsArgs, 'microApp' | 'actionName' | 'input'>, appUrl: string): ActionRequest;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"actions-client.d.ts","sourceRoot":"","sources":["../../src/lib/actions-client.ts"],"names":[],"mappings":"AAAA,MAAM,WAAW,iBAAiB;IAChC,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,KAAK,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;IAC/B,IAAI,EAAE,OAAO,CAAC;CACf;AAED,MAAM,WAAW,aAAa;IAC5B,GAAG,EAAE,MAAM,CAAC;IACZ,IAAI,EAAE,WAAW,CAAC;CACnB;AA2DD,wBAAgB,gBAAgB,CAAC,IAAI,EAAE,MAAM,EAAE,GAAG,iBAAiB,CAsDlE;AAED,wBAAgB,eAAe,CAAC,MAAM,EAAE,MAAM,
|
|
1
|
+
{"version":3,"file":"actions-client.d.ts","sourceRoot":"","sources":["../../src/lib/actions-client.ts"],"names":[],"mappings":"AAAA,MAAM,WAAW,iBAAiB;IAChC,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,KAAK,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;IAC/B,IAAI,EAAE,OAAO,CAAC;CACf;AAED,MAAM,WAAW,aAAa;IAC5B,GAAG,EAAE,MAAM,CAAC;IACZ,IAAI,EAAE,WAAW,CAAC;CACnB;AAED,MAAM,WAAW,0BAA0B;IACzC,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,GAAG,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,GAAG,SAAS,CAAC,CAAC;IACzC,OAAO,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,GAAG,SAAS,CAAC,CAAC;IAC7C,UAAU,EAAE,MAAM,CAAC;CACpB;AAOD,wBAAgB,mBAAmB,CAAC,EAClC,WAAW,EACX,GAAiB,EACjB,OAAY,EACZ,UAAU,GACX,EAAE,0BAA0B,UAS5B;AA2DD,wBAAgB,gBAAgB,CAAC,IAAI,EAAE,MAAM,EAAE,GAAG,iBAAiB,CAsDlE;AAED,wBAAgB,eAAe,CAAC,MAAM,EAAE,MAAM,UAS7C;AAED,wBAAgB,kBAAkB,CAAC,MAAM,EAAE,IAAI,CAAC,iBAAiB,EAAE,UAAU,GAAG,YAAY,GAAG,OAAO,CAAC,EAAE,MAAM,EAAE,MAAM,GAAG,aAAa,CAoBtI;AAED,wBAAsB,kBAAkB,CAAC,OAAO,EAAE,aAAa,GAAG,OAAO,CAAC,OAAO,CAAC,CAuBjF"}
|
|
@@ -1,3 +1,17 @@
|
|
|
1
|
+
function readUrlValue(value) {
|
|
2
|
+
const trimmed = value?.trim();
|
|
3
|
+
return trimmed || undefined;
|
|
4
|
+
}
|
|
5
|
+
export function resolveActionAppUrl({ explicitUrl, env = process.env, fileEnv = {}, defaultUrl, }) {
|
|
6
|
+
return readUrlValue(explicitUrl)
|
|
7
|
+
?? readUrlValue(env.DD_APP_URL)
|
|
8
|
+
?? readUrlValue(env.APP_URL)
|
|
9
|
+
?? readUrlValue(env.BETTER_AUTH_URL)
|
|
10
|
+
?? readUrlValue(fileEnv.DD_APP_URL)
|
|
11
|
+
?? readUrlValue(fileEnv.APP_URL)
|
|
12
|
+
?? readUrlValue(fileEnv.BETTER_AUTH_URL)
|
|
13
|
+
?? defaultUrl;
|
|
14
|
+
}
|
|
1
15
|
function requireValue(args, index, flag) {
|
|
2
16
|
const value = args[index + 1];
|
|
3
17
|
if (!value || value.startsWith('--')) {
|
|
@@ -115,7 +129,14 @@ export function parseActionsArgs(args) {
|
|
|
115
129
|
};
|
|
116
130
|
}
|
|
117
131
|
export function normalizeAppUrl(appUrl) {
|
|
118
|
-
|
|
132
|
+
const trimmed = appUrl.trim().replace(/\/+$/, '');
|
|
133
|
+
if (/^https?:\/\//i.test(trimmed)) {
|
|
134
|
+
return trimmed;
|
|
135
|
+
}
|
|
136
|
+
if (/^(localhost|127(?:\.\d{1,3}){3}|\[::1\])(?::|\/|$)/i.test(trimmed)) {
|
|
137
|
+
return `http://${trimmed}`;
|
|
138
|
+
}
|
|
139
|
+
return `https://${trimmed}`;
|
|
119
140
|
}
|
|
120
141
|
export function buildActionRequest(parsed, appUrl) {
|
|
121
142
|
if (!parsed.microApp) {
|
|
@@ -137,7 +158,15 @@ export function buildActionRequest(parsed, appUrl) {
|
|
|
137
158
|
};
|
|
138
159
|
}
|
|
139
160
|
export async function fetchActionRequest(request) {
|
|
140
|
-
|
|
161
|
+
let response;
|
|
162
|
+
try {
|
|
163
|
+
response = await fetch(request.url, request.init);
|
|
164
|
+
}
|
|
165
|
+
catch (error) {
|
|
166
|
+
const detail = error instanceof Error ? error.message : String(error);
|
|
167
|
+
throw new Error(`Unable to reach ${request.url}: ${detail}. ` +
|
|
168
|
+
'Set DD_APP_URL to the running Double Digit app URL, or pass --url.');
|
|
169
|
+
}
|
|
141
170
|
const text = await response.text();
|
|
142
171
|
const payload = text ? JSON.parse(text) : null;
|
|
143
172
|
if (!response.ok) {
|