devflare 1.0.0-next.22 → 1.0.0-next.23
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/LLM.md +144 -5
- package/dist/account-j8nfggg4.js +475 -0
- package/dist/account-qhe8vtds.js +475 -0
- package/dist/bridge/miniflare.d.ts +1 -1
- package/dist/bridge/miniflare.d.ts.map +1 -1
- package/dist/browser.d.ts +13 -13
- package/dist/browser.d.ts.map +1 -1
- package/dist/browser.js +4 -2
- package/dist/build-vy95gy3f.js +54 -0
- package/dist/build-yzx0gsaj.js +54 -0
- package/dist/cli/commands/build-artifacts.d.ts.map +1 -1
- package/dist/cli/commands/config.d.ts.map +1 -1
- package/dist/cli/commands/type-generation/generator.d.ts +4 -2
- package/dist/cli/commands/type-generation/generator.d.ts.map +1 -1
- package/dist/cli/commands/types.d.ts.map +1 -1
- package/dist/cli/index.js +1 -1
- package/dist/config/compiler/types.d.ts +1 -1
- package/dist/config/compiler/types.d.ts.map +1 -1
- package/dist/config/define.d.ts +7 -4
- package/dist/config/define.d.ts.map +1 -1
- package/dist/config/env-vars.d.ts +309 -0
- package/dist/config/env-vars.d.ts.map +1 -0
- package/dist/config/index.d.ts +2 -1
- package/dist/config/index.d.ts.map +1 -1
- package/dist/config/loader.d.ts.map +1 -1
- package/dist/config/local-dev-vars.d.ts +2 -2
- package/dist/config/local-dev-vars.d.ts.map +1 -1
- package/dist/config/schema-env.d.ts +6 -6
- package/dist/config/schema-types-bindings-platform.d.ts +378 -0
- package/dist/config/schema-types-bindings-platform.d.ts.map +1 -0
- package/dist/config/schema-types-bindings-resources.d.ts +551 -0
- package/dist/config/schema-types-bindings-resources.d.ts.map +1 -0
- package/dist/config/schema-types-bindings.d.ts +254 -0
- package/dist/config/schema-types-bindings.d.ts.map +1 -0
- package/dist/config/schema-types-build.d.ts +86 -0
- package/dist/config/schema-types-build.d.ts.map +1 -0
- package/dist/config/schema-types-runtime.d.ts +882 -0
- package/dist/config/schema-types-runtime.d.ts.map +1 -0
- package/dist/config/schema-types.d.ts +377 -0
- package/dist/config/schema-types.d.ts.map +1 -0
- package/dist/config/schema.d.ts +14 -15
- package/dist/config/schema.d.ts.map +1 -1
- package/dist/config-entry.d.ts +2 -0
- package/dist/config-entry.d.ts.map +1 -1
- package/dist/config-entry.js +3 -1
- package/dist/config-gq5jh4cx.js +105 -0
- package/dist/config-vec13050.js +105 -0
- package/dist/deploy-01j0ep5n.js +1055 -0
- package/dist/deploy-tjypkhg7.js +1055 -0
- package/dist/dev-bh581ew3.js +2597 -0
- package/dist/dev-gn5y93z9.js +2597 -0
- package/dist/dev-server/server.d.ts.map +1 -1
- package/dist/doctor-h5q28qt1.js +259 -0
- package/dist/doctor-khk550tw.js +259 -0
- package/dist/env.d.ts +10 -0
- package/dist/env.d.ts.map +1 -1
- package/dist/index-0bv2qjs1.js +1555 -0
- package/dist/index-3tkzn06q.js +413 -0
- package/dist/index-8fyz6gcm.js +699 -0
- package/dist/index-97z629zr.js +109 -0
- package/dist/index-b28c4yr4.js +1205 -0
- package/dist/index-c8p4njqy.js +479 -0
- package/dist/index-cr06zrgw.js +1033 -0
- package/dist/index-cwjjdtgn.js +74 -0
- package/dist/index-dref9ecb.js +476 -0
- package/dist/index-e151t4ge.js +895 -0
- package/dist/index-e7kakw0j.js +1033 -0
- package/dist/index-f1g5jdm8.js +1426 -0
- package/dist/index-f46984zs.js +1554 -0
- package/dist/index-grk8pzhr.js +185 -0
- package/dist/index-hzmpecq9.js +52 -0
- package/dist/index-j1csb7gb.js +581 -0
- package/dist/index-j7x7f72h.js +185 -0
- package/dist/index-jkqbjwt2.js +476 -0
- package/dist/index-mh5renra.js +895 -0
- package/dist/index-p9xq83p7.js +147 -0
- package/dist/index-q15nj71j.js +52 -0
- package/dist/index-qqp65pyv.js +699 -0
- package/dist/index-s0fmwxbk.js +74 -0
- package/dist/index-stzx8nc4.js +111 -0
- package/dist/index-th4vrnbk.js +1205 -0
- package/dist/index-vtcmsgaf.js +581 -0
- package/dist/index-x2k3awjs.js +147 -0
- package/dist/index-x8x547tz.js +1426 -0
- package/dist/index-xxxd0mvw.js +109 -0
- package/dist/index.d.ts +1 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +8 -6
- package/dist/login-280p2cm9.js +77 -0
- package/dist/login-4n266whq.js +77 -0
- package/dist/previews-3m3ffpaw.js +1337 -0
- package/dist/previews-tr8sm03d.js +1337 -0
- package/dist/productions-62y489ff.js +505 -0
- package/dist/productions-cgn3fz7d.js +505 -0
- package/dist/runtime/exports.d.ts +23 -0
- package/dist/runtime/exports.d.ts.map +1 -1
- package/dist/runtime/index.d.ts +1 -1
- package/dist/runtime/index.d.ts.map +1 -1
- package/dist/runtime/index.js +5 -3
- package/dist/secrets-4050kqf5.js +91 -0
- package/dist/secrets-p112cajt.js +91 -0
- package/dist/sveltekit/index.js +4 -4
- package/dist/test/index.js +23 -11
- package/dist/test/resolve-service-bindings.d.ts +1 -1
- package/dist/test/resolve-service-bindings.d.ts.map +1 -1
- package/dist/test/simple-context-lifecycle.d.ts.map +1 -1
- package/dist/types-apmt10yj.js +705 -0
- package/dist/types-ttrrgdfj.js +705 -0
- package/dist/vite/index.js +5 -5
- package/dist/vite/plugin-context.d.ts.map +1 -1
- package/dist/vite/plugin-programmatic.d.ts.map +1 -1
- package/dist/worker-2k1jyr6p.js +513 -0
- package/dist/worker-jqgn6jyj.js +513 -0
- package/package.json +1 -1
|
@@ -0,0 +1,109 @@
|
|
|
1
|
+
import {
|
|
2
|
+
bundleWorkerEntry
|
|
3
|
+
} from "./index-e151t4ge.js";
|
|
4
|
+
import {
|
|
5
|
+
DEFAULT_WORKFLOW_PATTERN,
|
|
6
|
+
findFiles
|
|
7
|
+
} from "./index-qwgr4q7s.js";
|
|
8
|
+
import {
|
|
9
|
+
normalizeWorkflowBinding
|
|
10
|
+
} from "./index-0bv2qjs1.js";
|
|
11
|
+
|
|
12
|
+
// src/workflows/local-workflow-entrypoints.ts
|
|
13
|
+
import { mkdir, readFile, writeFile } from "node:fs/promises";
|
|
14
|
+
import { join, relative, resolve } from "pathe";
|
|
15
|
+
function findExportedClasses(code) {
|
|
16
|
+
const classes = [];
|
|
17
|
+
const classPattern = /export\s+class\s+(\w+)/g;
|
|
18
|
+
let match;
|
|
19
|
+
while ((match = classPattern.exec(code)) !== null) {
|
|
20
|
+
classes.push(match[1]);
|
|
21
|
+
}
|
|
22
|
+
return classes;
|
|
23
|
+
}
|
|
24
|
+
function toImportSpecifier(fromDir, filePath) {
|
|
25
|
+
const relativePath = relative(fromDir, filePath).replace(/\\/g, "/");
|
|
26
|
+
return relativePath.startsWith(".") ? relativePath : `./${relativePath}`;
|
|
27
|
+
}
|
|
28
|
+
async function discoverWorkflowClasses(config, configDir) {
|
|
29
|
+
const classToFilePath = new Map;
|
|
30
|
+
const workflowPatternConfig = config.files?.workflows;
|
|
31
|
+
const workflowPattern = typeof workflowPatternConfig === "string" ? workflowPatternConfig : DEFAULT_WORKFLOW_PATTERN;
|
|
32
|
+
if (workflowPatternConfig === false) {
|
|
33
|
+
return classToFilePath;
|
|
34
|
+
}
|
|
35
|
+
const files = await findFiles(workflowPattern, { cwd: configDir });
|
|
36
|
+
for (const filePath of files) {
|
|
37
|
+
try {
|
|
38
|
+
const code = await readFile(filePath, "utf-8");
|
|
39
|
+
for (const className of findExportedClasses(code)) {
|
|
40
|
+
classToFilePath.set(className, filePath);
|
|
41
|
+
}
|
|
42
|
+
} catch {}
|
|
43
|
+
}
|
|
44
|
+
return classToFilePath;
|
|
45
|
+
}
|
|
46
|
+
async function resolveLocalWorkflowEntrypoints(config, configDir) {
|
|
47
|
+
const workflows = config.bindings?.workflows;
|
|
48
|
+
if (!workflows || Object.keys(workflows).length === 0) {
|
|
49
|
+
return [];
|
|
50
|
+
}
|
|
51
|
+
const classToFilePath = await discoverWorkflowClasses(config, configDir);
|
|
52
|
+
const entrypoints = [];
|
|
53
|
+
for (const [bindingName, binding] of Object.entries(workflows)) {
|
|
54
|
+
const normalized = normalizeWorkflowBinding(binding);
|
|
55
|
+
if (normalized.scriptName) {
|
|
56
|
+
continue;
|
|
57
|
+
}
|
|
58
|
+
const scriptPath = classToFilePath.get(normalized.className);
|
|
59
|
+
if (!scriptPath) {
|
|
60
|
+
throw new Error(`Workflow binding ${bindingName} (className: '${normalized.className}') not found.
|
|
61
|
+
` + `Either set files.workflows to match the workflow source file, or set scriptName when the workflow lives in another worker.`);
|
|
62
|
+
}
|
|
63
|
+
entrypoints.push({
|
|
64
|
+
bindingName,
|
|
65
|
+
className: normalized.className,
|
|
66
|
+
scriptPath
|
|
67
|
+
});
|
|
68
|
+
}
|
|
69
|
+
return entrypoints;
|
|
70
|
+
}
|
|
71
|
+
function buildWorkflowVirtualEntry(entrypoints, entryDir) {
|
|
72
|
+
const imports = entrypoints.map((entrypoint, index) => {
|
|
73
|
+
const importName = `__DevflareWorkflow${index}`;
|
|
74
|
+
const importPath = toImportSpecifier(entryDir, entrypoint.scriptPath);
|
|
75
|
+
return {
|
|
76
|
+
importName,
|
|
77
|
+
className: entrypoint.className,
|
|
78
|
+
line: `import { ${entrypoint.className} as ${importName} } from '${importPath}'`
|
|
79
|
+
};
|
|
80
|
+
});
|
|
81
|
+
const exports = imports.map((entrypoint) => {
|
|
82
|
+
return `export { ${entrypoint.importName} as ${entrypoint.className} }`;
|
|
83
|
+
});
|
|
84
|
+
return [...imports.map((entrypoint) => entrypoint.line), "", ...exports].join(`
|
|
85
|
+
`);
|
|
86
|
+
}
|
|
87
|
+
async function bundleWorkflowEntrypointScript(config, configDir, options = {}) {
|
|
88
|
+
const entrypoints = await resolveLocalWorkflowEntrypoints(config, configDir);
|
|
89
|
+
if (entrypoints.length === 0) {
|
|
90
|
+
return "";
|
|
91
|
+
}
|
|
92
|
+
const entryDir = resolve(configDir, ".devflare", "workflow-entrypoints");
|
|
93
|
+
const entryPath = join(entryDir, "__entry.ts");
|
|
94
|
+
const outFile = join(entryDir, "index.js");
|
|
95
|
+
await mkdir(entryDir, { recursive: true });
|
|
96
|
+
await writeFile(entryPath, buildWorkflowVirtualEntry(entrypoints, entryDir));
|
|
97
|
+
await bundleWorkerEntry({
|
|
98
|
+
cwd: configDir,
|
|
99
|
+
inputFile: entryPath,
|
|
100
|
+
outFile,
|
|
101
|
+
rolldownOptions: config.rolldown?.options,
|
|
102
|
+
sourcemap: config.rolldown?.sourcemap,
|
|
103
|
+
minify: config.rolldown?.minify,
|
|
104
|
+
logger: options.logger
|
|
105
|
+
});
|
|
106
|
+
return await readFile(outFile, "utf-8");
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
export { bundleWorkflowEntrypointScript };
|
package/dist/index.d.ts
CHANGED
|
@@ -4,6 +4,6 @@ export { workerName } from './workerName';
|
|
|
4
4
|
export { durableObject, getDurableObjectOptions, type DurableObjectOptions } from './decorators';
|
|
5
5
|
export { runCli, parseArgs } from './cli';
|
|
6
6
|
export type { ParsedArgs, CliOptions, CliResult } from './cli';
|
|
7
|
-
export { env } from './env';
|
|
7
|
+
export { env, vars } from './env';
|
|
8
8
|
export { defineConfig as default } from './config';
|
|
9
9
|
//# sourceMappingURL=index.d.ts.map
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAOA,OAAO,EACN,YAAY,EACZ,OAAO,EACP,UAAU,EACV,kBAAkB,EAClB,aAAa,EACb,eAAe,EACf,YAAY,EACZ,mBAAmB,EACnB,qBAAqB,EACrB,6BAA6B,EAC7B,KAAK,cAAc,EACnB,KAAK,mBAAmB,EACxB,KAAK,cAAc,EACnB,KAAK,mBAAmB,EACxB,KAAK,iBAAiB,EACtB,KAAK,wBAAwB,EAC7B,KAAK,yBAAyB,EAC9B,MAAM,UAAU,CAAA;AAGjB,OAAO,EACN,GAAG,EACH,KAAK,SAAS,EACd,KAAK,aAAa,EAClB,KAAK,qBAAqB,EAC1B,MAAM,UAAU,CAAA;AAGjB,OAAO,EAAE,UAAU,EAAE,MAAM,cAAc,CAAA;AAGzC,OAAO,EACN,aAAa,EACb,uBAAuB,EACvB,KAAK,oBAAoB,EACzB,MAAM,cAAc,CAAA;AAGrB,OAAO,EAAE,MAAM,EAAE,SAAS,EAAE,MAAM,OAAO,CAAA;AACzC,YAAY,EAAE,UAAU,EAAE,UAAU,EAAE,SAAS,EAAE,MAAM,OAAO,CAAA;AAG9D,OAAO,EAAE,GAAG,EAAE,MAAM,OAAO,CAAA;
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAOA,OAAO,EACN,YAAY,EACZ,OAAO,EACP,UAAU,EACV,kBAAkB,EAClB,aAAa,EACb,eAAe,EACf,YAAY,EACZ,mBAAmB,EACnB,qBAAqB,EACrB,6BAA6B,EAC7B,KAAK,cAAc,EACnB,KAAK,mBAAmB,EACxB,KAAK,cAAc,EACnB,KAAK,mBAAmB,EACxB,KAAK,iBAAiB,EACtB,KAAK,wBAAwB,EAC7B,KAAK,yBAAyB,EAC9B,MAAM,UAAU,CAAA;AAGjB,OAAO,EACN,GAAG,EACH,KAAK,SAAS,EACd,KAAK,aAAa,EAClB,KAAK,qBAAqB,EAC1B,MAAM,UAAU,CAAA;AAGjB,OAAO,EAAE,UAAU,EAAE,MAAM,cAAc,CAAA;AAGzC,OAAO,EACN,aAAa,EACb,uBAAuB,EACvB,KAAK,oBAAoB,EACzB,MAAM,cAAc,CAAA;AAGrB,OAAO,EAAE,MAAM,EAAE,SAAS,EAAE,MAAM,OAAO,CAAA;AACzC,YAAY,EAAE,UAAU,EAAE,UAAU,EAAE,SAAS,EAAE,MAAM,OAAO,CAAA;AAG9D,OAAO,EAAE,GAAG,EAAE,IAAI,EAAE,MAAM,OAAO,CAAA;AAGjC,OAAO,EAAE,YAAY,IAAI,OAAO,EAAE,MAAM,UAAU,CAAA"}
|
package/dist/index.js
CHANGED
|
@@ -4,13 +4,14 @@ import {
|
|
|
4
4
|
import {
|
|
5
5
|
parseArgs,
|
|
6
6
|
runCli
|
|
7
|
-
} from "./index-
|
|
7
|
+
} from "./index-x8x547tz.js";
|
|
8
8
|
import"./index-627srx16.js";
|
|
9
9
|
import"./index-stgn34cr.js";
|
|
10
10
|
import"./index-3t6rypgc.js";
|
|
11
11
|
import {
|
|
12
|
-
env
|
|
13
|
-
|
|
12
|
+
env,
|
|
13
|
+
vars
|
|
14
|
+
} from "./index-stzx8nc4.js";
|
|
14
15
|
import {
|
|
15
16
|
durableObject,
|
|
16
17
|
getDurableObjectOptions
|
|
@@ -20,7 +21,7 @@ import"./index-hpwa6vsw.js";
|
|
|
20
21
|
import {
|
|
21
22
|
compileConfig,
|
|
22
23
|
stringifyConfig
|
|
23
|
-
} from "./index-
|
|
24
|
+
} from "./index-8fyz6gcm.js";
|
|
24
25
|
import {
|
|
25
26
|
ConfigNotFoundError,
|
|
26
27
|
ConfigResourceResolutionError,
|
|
@@ -28,12 +29,12 @@ import {
|
|
|
28
29
|
configSchema,
|
|
29
30
|
loadConfig,
|
|
30
31
|
loadResolvedConfig
|
|
31
|
-
} from "./index-
|
|
32
|
+
} from "./index-0bv2qjs1.js";
|
|
32
33
|
import"./index-1d4jg11n.js";
|
|
33
34
|
import"./index-mg8vwqxf.js";
|
|
34
35
|
import {
|
|
35
36
|
preview
|
|
36
|
-
} from "./index-
|
|
37
|
+
} from "./index-c8p4njqy.js";
|
|
37
38
|
import {
|
|
38
39
|
defineConfig,
|
|
39
40
|
ref
|
|
@@ -41,6 +42,7 @@ import {
|
|
|
41
42
|
import"./index-37x76zdn.js";
|
|
42
43
|
export {
|
|
43
44
|
workerName,
|
|
45
|
+
vars,
|
|
44
46
|
stringifyConfig,
|
|
45
47
|
runCli,
|
|
46
48
|
ref,
|
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
import {
|
|
2
|
+
getConfiguredAccountId
|
|
3
|
+
} from "./index-s0fmwxbk.js";
|
|
4
|
+
import {
|
|
5
|
+
account
|
|
6
|
+
} from "./index-0m6e4mxz.js";
|
|
7
|
+
import"./index-k7m5f1dg.js";
|
|
8
|
+
import"./index-3jme4hgw.js";
|
|
9
|
+
import {
|
|
10
|
+
getDependencies
|
|
11
|
+
} from "./index-z9gy8w6b.js";
|
|
12
|
+
import {
|
|
13
|
+
createCliTheme,
|
|
14
|
+
dim,
|
|
15
|
+
green,
|
|
16
|
+
logLine,
|
|
17
|
+
whiteDim,
|
|
18
|
+
yellow
|
|
19
|
+
} from "./index-stgn34cr.js";
|
|
20
|
+
import"./index-3t6rypgc.js";
|
|
21
|
+
import"./index-15fpa5tx.js";
|
|
22
|
+
import"./index-0bv2qjs1.js";
|
|
23
|
+
import"./index-1d4jg11n.js";
|
|
24
|
+
import"./index-mg8vwqxf.js";
|
|
25
|
+
import"./index-c8p4njqy.js";
|
|
26
|
+
import"./index-37x76zdn.js";
|
|
27
|
+
|
|
28
|
+
// src/cli/commands/login.ts
|
|
29
|
+
async function logResolvedAccount(cwd, logger, theme) {
|
|
30
|
+
try {
|
|
31
|
+
const primaryAccount = await account.getPrimaryAccount();
|
|
32
|
+
if (primaryAccount) {
|
|
33
|
+
logLine(logger, `${dim("Primary account:", theme)} ${green(primaryAccount.name, theme)} ${whiteDim(`(${primaryAccount.id})`, theme)}`);
|
|
34
|
+
return;
|
|
35
|
+
}
|
|
36
|
+
} catch {}
|
|
37
|
+
const configuredAccountId = await getConfiguredAccountId(cwd);
|
|
38
|
+
if (!configuredAccountId) {
|
|
39
|
+
logLine(logger, dim("Run `devflare account` to inspect available accounts.", theme));
|
|
40
|
+
return;
|
|
41
|
+
}
|
|
42
|
+
const configuredAccount = await account.getAccountById(configuredAccountId);
|
|
43
|
+
if (configuredAccount) {
|
|
44
|
+
logLine(logger, `${dim("Configured account:", theme)} ${green(configuredAccount.name, theme)} ${whiteDim(`(${configuredAccount.id})`, theme)}`);
|
|
45
|
+
return;
|
|
46
|
+
}
|
|
47
|
+
logLine(logger, `${dim("Configured account ID:", theme)} ${whiteDim(configuredAccountId, theme)}`);
|
|
48
|
+
logLine(logger, dim("Run `devflare account --account <id>` to inspect the configured account.", theme));
|
|
49
|
+
}
|
|
50
|
+
async function runLoginCommand(parsed, logger, options) {
|
|
51
|
+
const force = parsed.options.force === true;
|
|
52
|
+
const cwd = options.cwd ?? process.cwd();
|
|
53
|
+
const theme = createCliTheme(parsed.options);
|
|
54
|
+
if (!force && await account.isAuthenticated()) {
|
|
55
|
+
logger.success("Already authenticated with Cloudflare");
|
|
56
|
+
await logResolvedAccount(cwd, logger, theme);
|
|
57
|
+
logLine(logger, dim("Use `devflare login --force` to open Wrangler login again.", theme));
|
|
58
|
+
return { exitCode: 0 };
|
|
59
|
+
}
|
|
60
|
+
logLine(logger);
|
|
61
|
+
logLine(logger, `${yellow("login", theme)} ${dim("Opening Wrangler login…", theme)}`);
|
|
62
|
+
const deps = await getDependencies();
|
|
63
|
+
const result = await deps.exec.exec("bunx", ["wrangler", "login"], {
|
|
64
|
+
cwd,
|
|
65
|
+
stdio: "inherit"
|
|
66
|
+
});
|
|
67
|
+
if (result.exitCode !== 0) {
|
|
68
|
+
logger.error("Wrangler login failed");
|
|
69
|
+
return { exitCode: 1 };
|
|
70
|
+
}
|
|
71
|
+
logger.success("Authenticated with Cloudflare");
|
|
72
|
+
await logResolvedAccount(cwd, logger, theme);
|
|
73
|
+
return { exitCode: 0 };
|
|
74
|
+
}
|
|
75
|
+
export {
|
|
76
|
+
runLoginCommand
|
|
77
|
+
};
|
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
import {
|
|
2
|
+
getConfiguredAccountId
|
|
3
|
+
} from "./index-cwjjdtgn.js";
|
|
4
|
+
import {
|
|
5
|
+
account
|
|
6
|
+
} from "./index-0m6e4mxz.js";
|
|
7
|
+
import"./index-k7m5f1dg.js";
|
|
8
|
+
import"./index-3jme4hgw.js";
|
|
9
|
+
import {
|
|
10
|
+
getDependencies
|
|
11
|
+
} from "./index-z9gy8w6b.js";
|
|
12
|
+
import {
|
|
13
|
+
createCliTheme,
|
|
14
|
+
dim,
|
|
15
|
+
green,
|
|
16
|
+
logLine,
|
|
17
|
+
whiteDim,
|
|
18
|
+
yellow
|
|
19
|
+
} from "./index-stgn34cr.js";
|
|
20
|
+
import"./index-3t6rypgc.js";
|
|
21
|
+
import"./index-15fpa5tx.js";
|
|
22
|
+
import"./index-f46984zs.js";
|
|
23
|
+
import"./index-1d4jg11n.js";
|
|
24
|
+
import"./index-mg8vwqxf.js";
|
|
25
|
+
import"./index-c8p4njqy.js";
|
|
26
|
+
import"./index-37x76zdn.js";
|
|
27
|
+
|
|
28
|
+
// src/cli/commands/login.ts
|
|
29
|
+
async function logResolvedAccount(cwd, logger, theme) {
|
|
30
|
+
try {
|
|
31
|
+
const primaryAccount = await account.getPrimaryAccount();
|
|
32
|
+
if (primaryAccount) {
|
|
33
|
+
logLine(logger, `${dim("Primary account:", theme)} ${green(primaryAccount.name, theme)} ${whiteDim(`(${primaryAccount.id})`, theme)}`);
|
|
34
|
+
return;
|
|
35
|
+
}
|
|
36
|
+
} catch {}
|
|
37
|
+
const configuredAccountId = await getConfiguredAccountId(cwd);
|
|
38
|
+
if (!configuredAccountId) {
|
|
39
|
+
logLine(logger, dim("Run `devflare account` to inspect available accounts.", theme));
|
|
40
|
+
return;
|
|
41
|
+
}
|
|
42
|
+
const configuredAccount = await account.getAccountById(configuredAccountId);
|
|
43
|
+
if (configuredAccount) {
|
|
44
|
+
logLine(logger, `${dim("Configured account:", theme)} ${green(configuredAccount.name, theme)} ${whiteDim(`(${configuredAccount.id})`, theme)}`);
|
|
45
|
+
return;
|
|
46
|
+
}
|
|
47
|
+
logLine(logger, `${dim("Configured account ID:", theme)} ${whiteDim(configuredAccountId, theme)}`);
|
|
48
|
+
logLine(logger, dim("Run `devflare account --account <id>` to inspect the configured account.", theme));
|
|
49
|
+
}
|
|
50
|
+
async function runLoginCommand(parsed, logger, options) {
|
|
51
|
+
const force = parsed.options.force === true;
|
|
52
|
+
const cwd = options.cwd ?? process.cwd();
|
|
53
|
+
const theme = createCliTheme(parsed.options);
|
|
54
|
+
if (!force && await account.isAuthenticated()) {
|
|
55
|
+
logger.success("Already authenticated with Cloudflare");
|
|
56
|
+
await logResolvedAccount(cwd, logger, theme);
|
|
57
|
+
logLine(logger, dim("Use `devflare login --force` to open Wrangler login again.", theme));
|
|
58
|
+
return { exitCode: 0 };
|
|
59
|
+
}
|
|
60
|
+
logLine(logger);
|
|
61
|
+
logLine(logger, `${yellow("login", theme)} ${dim("Opening Wrangler login…", theme)}`);
|
|
62
|
+
const deps = await getDependencies();
|
|
63
|
+
const result = await deps.exec.exec("bunx", ["wrangler", "login"], {
|
|
64
|
+
cwd,
|
|
65
|
+
stdio: "inherit"
|
|
66
|
+
});
|
|
67
|
+
if (result.exitCode !== 0) {
|
|
68
|
+
logger.error("Wrangler login failed");
|
|
69
|
+
return { exitCode: 1 };
|
|
70
|
+
}
|
|
71
|
+
logger.success("Authenticated with Cloudflare");
|
|
72
|
+
await logResolvedAccount(cwd, logger, theme);
|
|
73
|
+
return { exitCode: 0 };
|
|
74
|
+
}
|
|
75
|
+
export {
|
|
76
|
+
runLoginCommand
|
|
77
|
+
};
|