@wraps.dev/cli 2.17.6 → 2.17.7
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/dist/cli.js
CHANGED
|
@@ -12,9 +12,13 @@ var __export = (target, all6) => {
|
|
|
12
12
|
// ../../node_modules/.pnpm/tsup@8.5.1_jiti@2.6.1_postcss@8.5.6_tsx@4.20.6_typescript@5.9.3_yaml@2.8.2/node_modules/tsup/assets/esm_shims.js
|
|
13
13
|
import path from "path";
|
|
14
14
|
import { fileURLToPath } from "url";
|
|
15
|
+
var getFilename, getDirname, __dirname;
|
|
15
16
|
var init_esm_shims = __esm({
|
|
16
17
|
"../../node_modules/.pnpm/tsup@8.5.1_jiti@2.6.1_postcss@8.5.6_tsx@4.20.6_typescript@5.9.3_yaml@2.8.2/node_modules/tsup/assets/esm_shims.js"() {
|
|
17
18
|
"use strict";
|
|
19
|
+
getFilename = () => fileURLToPath(import.meta.url);
|
|
20
|
+
getDirname = () => path.dirname(getFilename());
|
|
21
|
+
__dirname = /* @__PURE__ */ getDirname();
|
|
18
22
|
}
|
|
19
23
|
});
|
|
20
24
|
|
|
@@ -5622,6 +5626,8 @@ __export(dist_exports, {
|
|
|
5622
5626
|
retentionToDays: () => retentionToDays2
|
|
5623
5627
|
});
|
|
5624
5628
|
import { createHmac } from "crypto";
|
|
5629
|
+
import { dirname as dirname3, join as join8 } from "path";
|
|
5630
|
+
import { fileURLToPath as fileURLToPath3 } from "url";
|
|
5625
5631
|
function retentionToDays2(retention) {
|
|
5626
5632
|
switch (retention) {
|
|
5627
5633
|
case "7days":
|
|
@@ -5741,6 +5747,10 @@ function getSMTPConnectionDetails(region) {
|
|
|
5741
5747
|
// Use STARTTLS
|
|
5742
5748
|
};
|
|
5743
5749
|
}
|
|
5750
|
+
function resolvePackagePath(relativePath) {
|
|
5751
|
+
const dir = typeof __dirname !== "undefined" ? __dirname : dirname3(fileURLToPath3(import.meta.url));
|
|
5752
|
+
return join8(dir, "..", relativePath);
|
|
5753
|
+
}
|
|
5744
5754
|
var DEFAULT_EVENT_TYPES, ALL_EVENT_TYPES, DEFAULT_SUPPRESSION_REASONS, DEFAULT_CONFIG_SET_NAME, DEFAULT_MAIL_FROM_SUBDOMAIN, DEFAULT_HISTORY_RETENTION, VERCEL_OIDC_URL, VERCEL_OIDC_THUMBPRINT, RESOURCE_PREFIX, DEFAULT_TAGS, LAMBDA_EVENT_PROCESSOR_PATH, LAMBDA_SMS_EVENT_PROCESSOR_PATH;
|
|
5745
5755
|
var init_dist = __esm({
|
|
5746
5756
|
"../core/dist/index.js"() {
|
|
@@ -5779,14 +5789,12 @@ var init_dist = __esm({
|
|
|
5779
5789
|
DEFAULT_TAGS = {
|
|
5780
5790
|
ManagedBy: "wraps"
|
|
5781
5791
|
};
|
|
5782
|
-
LAMBDA_EVENT_PROCESSOR_PATH =
|
|
5783
|
-
"
|
|
5784
|
-
|
|
5785
|
-
|
|
5786
|
-
|
|
5787
|
-
|
|
5788
|
-
import.meta.url
|
|
5789
|
-
).pathname;
|
|
5792
|
+
LAMBDA_EVENT_PROCESSOR_PATH = resolvePackagePath(
|
|
5793
|
+
"lambda/event-processor"
|
|
5794
|
+
);
|
|
5795
|
+
LAMBDA_SMS_EVENT_PROCESSOR_PATH = resolvePackagePath(
|
|
5796
|
+
"lambda/sms-event-processor"
|
|
5797
|
+
);
|
|
5790
5798
|
}
|
|
5791
5799
|
});
|
|
5792
5800
|
|
|
@@ -5895,19 +5903,19 @@ import { randomBytes as randomBytes2 } from "crypto";
|
|
|
5895
5903
|
import { existsSync as existsSync7, mkdirSync } from "fs";
|
|
5896
5904
|
import { builtinModules } from "module";
|
|
5897
5905
|
import { tmpdir } from "os";
|
|
5898
|
-
import { dirname as
|
|
5899
|
-
import { fileURLToPath as
|
|
5906
|
+
import { dirname as dirname4, join as join9 } from "path";
|
|
5907
|
+
import { fileURLToPath as fileURLToPath4 } from "url";
|
|
5900
5908
|
import * as aws8 from "@pulumi/aws";
|
|
5901
5909
|
import * as pulumi11 from "@pulumi/pulumi";
|
|
5902
5910
|
import { build } from "esbuild";
|
|
5903
5911
|
function getPackageRoot() {
|
|
5904
|
-
const currentFile =
|
|
5905
|
-
let dir =
|
|
5906
|
-
while (dir !==
|
|
5907
|
-
if (existsSync7(
|
|
5912
|
+
const currentFile = fileURLToPath4(import.meta.url);
|
|
5913
|
+
let dir = dirname4(currentFile);
|
|
5914
|
+
while (dir !== dirname4(dir)) {
|
|
5915
|
+
if (existsSync7(join9(dir, "package.json"))) {
|
|
5908
5916
|
return dir;
|
|
5909
5917
|
}
|
|
5910
|
-
dir =
|
|
5918
|
+
dir = dirname4(dir);
|
|
5911
5919
|
}
|
|
5912
5920
|
throw new Error("Could not find package.json");
|
|
5913
5921
|
}
|
|
@@ -5931,17 +5939,17 @@ async function findEventSourceMapping(functionName, queueArn) {
|
|
|
5931
5939
|
}
|
|
5932
5940
|
async function getLambdaCode(functionName) {
|
|
5933
5941
|
const packageRoot = getPackageRoot();
|
|
5934
|
-
const distLambdaPath =
|
|
5935
|
-
const distBundleMarker =
|
|
5942
|
+
const distLambdaPath = join9(packageRoot, "dist", "lambda", functionName);
|
|
5943
|
+
const distBundleMarker = join9(distLambdaPath, ".bundled");
|
|
5936
5944
|
if (existsSync7(distBundleMarker)) {
|
|
5937
5945
|
return distLambdaPath;
|
|
5938
5946
|
}
|
|
5939
|
-
const lambdaPath =
|
|
5940
|
-
const lambdaBundleMarker =
|
|
5947
|
+
const lambdaPath = join9(packageRoot, "lambda", functionName);
|
|
5948
|
+
const lambdaBundleMarker = join9(lambdaPath, ".bundled");
|
|
5941
5949
|
if (existsSync7(lambdaBundleMarker)) {
|
|
5942
5950
|
return lambdaPath;
|
|
5943
5951
|
}
|
|
5944
|
-
const sourcePath =
|
|
5952
|
+
const sourcePath = join9(lambdaPath, "index.ts");
|
|
5945
5953
|
if (!existsSync7(sourcePath)) {
|
|
5946
5954
|
throw new Error(
|
|
5947
5955
|
`Lambda source not found: ${sourcePath}
|
|
@@ -5950,7 +5958,7 @@ Try running: pnpm build`
|
|
|
5950
5958
|
);
|
|
5951
5959
|
}
|
|
5952
5960
|
const buildId = randomBytes2(8).toString("hex");
|
|
5953
|
-
const outdir =
|
|
5961
|
+
const outdir = join9(tmpdir(), `wraps-lambda-${buildId}`);
|
|
5954
5962
|
if (!existsSync7(outdir)) {
|
|
5955
5963
|
mkdirSync(outdir, { recursive: true });
|
|
5956
5964
|
}
|
|
@@ -5960,7 +5968,7 @@ Try running: pnpm build`
|
|
|
5960
5968
|
platform: "node",
|
|
5961
5969
|
target: "node24",
|
|
5962
5970
|
format: "cjs",
|
|
5963
|
-
outfile:
|
|
5971
|
+
outfile: join9(outdir, "index.js"),
|
|
5964
5972
|
external: ["@aws-sdk/*", ...nodeBuiltins],
|
|
5965
5973
|
minify: true,
|
|
5966
5974
|
sourcemap: false
|
|
@@ -6041,8 +6049,8 @@ async function deployLambdaFunctions(config2) {
|
|
|
6041
6049
|
handler: "index.handler",
|
|
6042
6050
|
role: lambdaRole.arn,
|
|
6043
6051
|
code: new pulumi11.asset.FileArchive(eventProcessorCode),
|
|
6044
|
-
timeout:
|
|
6045
|
-
//
|
|
6052
|
+
timeout: 300,
|
|
6053
|
+
// 5 minutes (matches SQS visibility timeout)
|
|
6046
6054
|
memorySize: 512,
|
|
6047
6055
|
environment: lambdaEnvironment,
|
|
6048
6056
|
tags: {
|
|
@@ -6061,8 +6069,8 @@ async function deployLambdaFunctions(config2) {
|
|
|
6061
6069
|
handler: "index.handler",
|
|
6062
6070
|
role: lambdaRole.arn,
|
|
6063
6071
|
code: new pulumi11.asset.FileArchive(eventProcessorCode),
|
|
6064
|
-
timeout:
|
|
6065
|
-
//
|
|
6072
|
+
timeout: 300,
|
|
6073
|
+
// 5 minutes (matches SQS visibility timeout)
|
|
6066
6074
|
memorySize: 512,
|
|
6067
6075
|
environment: lambdaEnvironment,
|
|
6068
6076
|
tags: {
|
|
@@ -9102,8 +9110,8 @@ var init_dynamodb_metrics = __esm({
|
|
|
9102
9110
|
// src/cli.ts
|
|
9103
9111
|
init_esm_shims();
|
|
9104
9112
|
import { readFileSync as readFileSync3 } from "fs";
|
|
9105
|
-
import { dirname as
|
|
9106
|
-
import { fileURLToPath as
|
|
9113
|
+
import { dirname as dirname5, join as join21 } from "path";
|
|
9114
|
+
import { fileURLToPath as fileURLToPath6 } from "url";
|
|
9107
9115
|
import * as clack50 from "@clack/prompts";
|
|
9108
9116
|
import args from "args";
|
|
9109
9117
|
import pc53 from "picocolors";
|
|
@@ -16980,8 +16988,8 @@ async function createSQSResources() {
|
|
|
16980
16988
|
});
|
|
16981
16989
|
const queue = new aws11.sqs.Queue("wraps-email-events", {
|
|
16982
16990
|
name: "wraps-email-events",
|
|
16983
|
-
visibilityTimeoutSeconds:
|
|
16984
|
-
// Must be >= Lambda timeout
|
|
16991
|
+
visibilityTimeoutSeconds: 300,
|
|
16992
|
+
// Must be >= Lambda timeout (5 minutes)
|
|
16985
16993
|
messageRetentionSeconds: 345600,
|
|
16986
16994
|
// 4 days
|
|
16987
16995
|
receiveWaitTimeSeconds: 20,
|
|
@@ -21738,7 +21746,7 @@ init_json_output();
|
|
|
21738
21746
|
init_output();
|
|
21739
21747
|
import { existsSync as existsSync9 } from "fs";
|
|
21740
21748
|
import { mkdir as mkdir3, readFile as readFile4, writeFile as writeFile5 } from "fs/promises";
|
|
21741
|
-
import { join as
|
|
21749
|
+
import { join as join11 } from "path";
|
|
21742
21750
|
import * as clack26 from "@clack/prompts";
|
|
21743
21751
|
import pc27 from "picocolors";
|
|
21744
21752
|
|
|
@@ -21746,7 +21754,7 @@ import pc27 from "picocolors";
|
|
|
21746
21754
|
init_esm_shims();
|
|
21747
21755
|
import { existsSync as existsSync8 } from "fs";
|
|
21748
21756
|
import { mkdir as mkdir2, readFile as readFile3, writeFile as writeFile4 } from "fs/promises";
|
|
21749
|
-
import { join as
|
|
21757
|
+
import { join as join10 } from "path";
|
|
21750
21758
|
var CLAUDE_MD_HEADER = `# Wraps
|
|
21751
21759
|
|
|
21752
21760
|
This project uses [Wraps](https://wraps.dev) for email infrastructure.
|
|
@@ -21756,8 +21764,8 @@ async function scaffoldClaudeMdSection({
|
|
|
21756
21764
|
sectionId,
|
|
21757
21765
|
sectionContent
|
|
21758
21766
|
}) {
|
|
21759
|
-
const claudeDir =
|
|
21760
|
-
const claudeMdPath =
|
|
21767
|
+
const claudeDir = join10(projectDir, ".claude");
|
|
21768
|
+
const claudeMdPath = join10(claudeDir, "CLAUDE.md");
|
|
21761
21769
|
await mkdir2(claudeDir, { recursive: true });
|
|
21762
21770
|
const startMarker = `<!-- wraps:${sectionId}-start -->`;
|
|
21763
21771
|
const endMarker = `<!-- wraps:${sectionId}-end -->`;
|
|
@@ -21798,8 +21806,8 @@ async function scaffoldClaudeSkill({
|
|
|
21798
21806
|
skillName,
|
|
21799
21807
|
skillContent
|
|
21800
21808
|
}) {
|
|
21801
|
-
const skillDir =
|
|
21802
|
-
const skillPath =
|
|
21809
|
+
const skillDir = join10(projectDir, ".claude", "skills", skillName);
|
|
21810
|
+
const skillPath = join10(skillDir, "SKILL.md");
|
|
21803
21811
|
await mkdir2(skillDir, { recursive: true });
|
|
21804
21812
|
await writeFile4(skillPath, `${skillContent.trim()}
|
|
21805
21813
|
`, "utf-8");
|
|
@@ -22184,7 +22192,7 @@ wraps email templates preview # Preview in browser
|
|
|
22184
22192
|
async function templatesInit(options) {
|
|
22185
22193
|
const startTime = Date.now();
|
|
22186
22194
|
const cwd = process.cwd();
|
|
22187
|
-
const wrapsDir =
|
|
22195
|
+
const wrapsDir = join11(cwd, "wraps");
|
|
22188
22196
|
if (!isJsonMode()) {
|
|
22189
22197
|
clack26.intro(pc27.bold("Templates as Code"));
|
|
22190
22198
|
}
|
|
@@ -22224,7 +22232,7 @@ async function templatesInit(options) {
|
|
|
22224
22232
|
let detectedDomain;
|
|
22225
22233
|
let detectedRegion;
|
|
22226
22234
|
try {
|
|
22227
|
-
const pkgPath =
|
|
22235
|
+
const pkgPath = join11(cwd, "package.json");
|
|
22228
22236
|
if (existsSync9(pkgPath)) {
|
|
22229
22237
|
const pkg = JSON.parse(await readFile4(pkgPath, "utf-8"));
|
|
22230
22238
|
if (pkg.homepage) {
|
|
@@ -22239,7 +22247,7 @@ async function templatesInit(options) {
|
|
|
22239
22247
|
}
|
|
22240
22248
|
try {
|
|
22241
22249
|
const { homedir: homedir4 } = await import("os");
|
|
22242
|
-
const connectionsDir =
|
|
22250
|
+
const connectionsDir = join11(homedir4(), ".wraps", "connections");
|
|
22243
22251
|
if (existsSync9(connectionsDir)) {
|
|
22244
22252
|
const { readdir: readdir5 } = await import("fs/promises");
|
|
22245
22253
|
const files = await readdir5(connectionsDir);
|
|
@@ -22255,33 +22263,33 @@ async function templatesInit(options) {
|
|
|
22255
22263
|
}
|
|
22256
22264
|
progress.start("Creating wraps/ directory structure");
|
|
22257
22265
|
await mkdir3(wrapsDir, { recursive: true });
|
|
22258
|
-
await mkdir3(
|
|
22259
|
-
await mkdir3(
|
|
22260
|
-
await mkdir3(
|
|
22261
|
-
await mkdir3(
|
|
22266
|
+
await mkdir3(join11(wrapsDir, "templates"), { recursive: true });
|
|
22267
|
+
await mkdir3(join11(wrapsDir, "templates", "_components"), { recursive: true });
|
|
22268
|
+
await mkdir3(join11(wrapsDir, "workflows"), { recursive: true });
|
|
22269
|
+
await mkdir3(join11(wrapsDir, ".wraps"), { recursive: true });
|
|
22262
22270
|
const configContent = generateConfigFile(
|
|
22263
22271
|
orgSlug,
|
|
22264
22272
|
detectedDomain,
|
|
22265
22273
|
detectedRegion
|
|
22266
22274
|
);
|
|
22267
|
-
await writeFile5(
|
|
22275
|
+
await writeFile5(join11(wrapsDir, "wraps.config.ts"), configContent, "utf-8");
|
|
22268
22276
|
const brandContent = generateBrandFile();
|
|
22269
|
-
await writeFile5(
|
|
22277
|
+
await writeFile5(join11(wrapsDir, "brand.ts"), brandContent, "utf-8");
|
|
22270
22278
|
if (!options.noExample) {
|
|
22271
22279
|
await writeFile5(
|
|
22272
|
-
|
|
22280
|
+
join11(wrapsDir, "templates", "welcome.tsx"),
|
|
22273
22281
|
generateWelcomeTemplate(),
|
|
22274
22282
|
"utf-8"
|
|
22275
22283
|
);
|
|
22276
22284
|
await writeFile5(
|
|
22277
|
-
|
|
22285
|
+
join11(wrapsDir, "templates", "_components", "footer.tsx"),
|
|
22278
22286
|
generateFooterComponent(),
|
|
22279
22287
|
"utf-8"
|
|
22280
22288
|
);
|
|
22281
22289
|
}
|
|
22282
|
-
const gitignorePath =
|
|
22290
|
+
const gitignorePath = join11(wrapsDir, ".gitignore");
|
|
22283
22291
|
await writeFile5(gitignorePath, ".wraps/\n", "utf-8");
|
|
22284
|
-
const rootGitignorePath =
|
|
22292
|
+
const rootGitignorePath = join11(cwd, ".gitignore");
|
|
22285
22293
|
if (existsSync9(rootGitignorePath)) {
|
|
22286
22294
|
const gitignoreContent = await readFile4(rootGitignorePath, "utf-8");
|
|
22287
22295
|
if (!gitignoreContent.includes("wraps/.wraps")) {
|
|
@@ -22554,7 +22562,7 @@ const unsubscribeLink = {
|
|
|
22554
22562
|
init_esm_shims();
|
|
22555
22563
|
init_events();
|
|
22556
22564
|
import { existsSync as existsSync11, watch } from "fs";
|
|
22557
|
-
import { join as
|
|
22565
|
+
import { join as join13 } from "path";
|
|
22558
22566
|
import * as clack27 from "@clack/prompts";
|
|
22559
22567
|
import pc28 from "picocolors";
|
|
22560
22568
|
|
|
@@ -22562,14 +22570,14 @@ import pc28 from "picocolors";
|
|
|
22562
22570
|
init_esm_shims();
|
|
22563
22571
|
import { existsSync as existsSync10 } from "fs";
|
|
22564
22572
|
import { mkdir as mkdir4, readdir as readdir3, writeFile as writeFile6 } from "fs/promises";
|
|
22565
|
-
import { join as
|
|
22573
|
+
import { join as join12 } from "path";
|
|
22566
22574
|
async function loadWrapsConfig(wrapsDir) {
|
|
22567
|
-
const configPath =
|
|
22575
|
+
const configPath = join12(wrapsDir, "wraps.config.ts");
|
|
22568
22576
|
const { build: build2 } = await import("esbuild");
|
|
22569
|
-
const shimDir =
|
|
22577
|
+
const shimDir = join12(wrapsDir, ".wraps", "_shims");
|
|
22570
22578
|
await mkdir4(shimDir, { recursive: true });
|
|
22571
22579
|
await writeFile6(
|
|
22572
|
-
|
|
22580
|
+
join12(shimDir, "wraps-client-shim.mjs"),
|
|
22573
22581
|
"export const defineConfig = (c) => c;\nexport const defineBrand = (b) => b;\n",
|
|
22574
22582
|
"utf-8"
|
|
22575
22583
|
);
|
|
@@ -22581,11 +22589,11 @@ async function loadWrapsConfig(wrapsDir) {
|
|
|
22581
22589
|
platform: "node",
|
|
22582
22590
|
target: "node20",
|
|
22583
22591
|
alias: {
|
|
22584
|
-
"@wraps.dev/client":
|
|
22592
|
+
"@wraps.dev/client": join12(shimDir, "wraps-client-shim.mjs")
|
|
22585
22593
|
}
|
|
22586
22594
|
});
|
|
22587
22595
|
const code = result.outputFiles[0].text;
|
|
22588
|
-
const tmpPath =
|
|
22596
|
+
const tmpPath = join12(wrapsDir, ".wraps", "_config.mjs");
|
|
22589
22597
|
await writeFile6(tmpPath, code, "utf-8");
|
|
22590
22598
|
const mod = await import(tmpPath);
|
|
22591
22599
|
const config2 = mod.default;
|
|
@@ -22610,7 +22618,7 @@ async function findCliNodeModules() {
|
|
|
22610
22618
|
const paths = [];
|
|
22611
22619
|
try {
|
|
22612
22620
|
const { createRequire } = await import("module");
|
|
22613
|
-
const { dirname:
|
|
22621
|
+
const { dirname: dirname6 } = await import("path");
|
|
22614
22622
|
for (const base of [
|
|
22615
22623
|
// The current file's location (works when running from source)
|
|
22616
22624
|
import.meta.url,
|
|
@@ -22620,8 +22628,8 @@ async function findCliNodeModules() {
|
|
|
22620
22628
|
try {
|
|
22621
22629
|
const req = createRequire(base);
|
|
22622
22630
|
const reactPkg = req.resolve("react/package.json");
|
|
22623
|
-
const reactNodeModules =
|
|
22624
|
-
if (existsSync10(
|
|
22631
|
+
const reactNodeModules = join12(dirname6(reactPkg), "..");
|
|
22632
|
+
if (existsSync10(join12(reactNodeModules, "react"))) {
|
|
22625
22633
|
paths.push(reactNodeModules);
|
|
22626
22634
|
break;
|
|
22627
22635
|
}
|
|
@@ -22649,10 +22657,10 @@ async function compileForPreview(filePath, slug, wrapsDir) {
|
|
|
22649
22657
|
}
|
|
22650
22658
|
});
|
|
22651
22659
|
const bundledCode = result.outputFiles[0].text;
|
|
22652
|
-
const projectRoot =
|
|
22653
|
-
const tmpDir =
|
|
22660
|
+
const projectRoot = join12(wrapsDir, "..");
|
|
22661
|
+
const tmpDir = join12(projectRoot, "node_modules", ".wraps-compiled");
|
|
22654
22662
|
await mkdir4(tmpDir, { recursive: true });
|
|
22655
|
-
const tmpPath =
|
|
22663
|
+
const tmpPath = join12(tmpDir, `${slug}.preview.mjs`);
|
|
22656
22664
|
await writeFile6(tmpPath, bundledCode, "utf-8");
|
|
22657
22665
|
const mod = await import(`${tmpPath}?t=${Date.now()}`);
|
|
22658
22666
|
const Component = mod.default;
|
|
@@ -22675,14 +22683,14 @@ async function compileForPreview(filePath, slug, wrapsDir) {
|
|
|
22675
22683
|
init_errors();
|
|
22676
22684
|
async function templatesPreview(options) {
|
|
22677
22685
|
const cwd = process.cwd();
|
|
22678
|
-
const wrapsDir =
|
|
22679
|
-
const configPath =
|
|
22686
|
+
const wrapsDir = join13(cwd, "wraps");
|
|
22687
|
+
const configPath = join13(wrapsDir, "wraps.config.ts");
|
|
22680
22688
|
if (!existsSync11(configPath)) {
|
|
22681
22689
|
throw errors.wrapsConfigNotFound();
|
|
22682
22690
|
}
|
|
22683
22691
|
clack27.intro(pc28.bold("Preview Templates"));
|
|
22684
22692
|
const config2 = await loadWrapsConfig(wrapsDir);
|
|
22685
|
-
const templatesDir =
|
|
22693
|
+
const templatesDir = join13(wrapsDir, config2.templatesDir || "./templates");
|
|
22686
22694
|
if (!existsSync11(templatesDir)) {
|
|
22687
22695
|
throw errors.wrapsConfigNotFound();
|
|
22688
22696
|
}
|
|
@@ -22702,7 +22710,7 @@ async function templatesPreview(options) {
|
|
|
22702
22710
|
throw new Error(`Template not found: ${slug}`);
|
|
22703
22711
|
}
|
|
22704
22712
|
const result = await compileForPreview(
|
|
22705
|
-
|
|
22713
|
+
join13(templatesDir, file),
|
|
22706
22714
|
slug,
|
|
22707
22715
|
wrapsDir
|
|
22708
22716
|
);
|
|
@@ -23006,7 +23014,7 @@ init_events();
|
|
|
23006
23014
|
import { createHash } from "crypto";
|
|
23007
23015
|
import { existsSync as existsSync13 } from "fs";
|
|
23008
23016
|
import { mkdir as mkdir6, readFile as readFile6, writeFile as writeFile8 } from "fs/promises";
|
|
23009
|
-
import { join as
|
|
23017
|
+
import { join as join15 } from "path";
|
|
23010
23018
|
import * as clack28 from "@clack/prompts";
|
|
23011
23019
|
import pc29 from "picocolors";
|
|
23012
23020
|
init_config();
|
|
@@ -23017,9 +23025,9 @@ init_json_output();
|
|
|
23017
23025
|
init_esm_shims();
|
|
23018
23026
|
import { existsSync as existsSync12 } from "fs";
|
|
23019
23027
|
import { mkdir as mkdir5, readFile as readFile5, writeFile as writeFile7 } from "fs/promises";
|
|
23020
|
-
import { join as
|
|
23028
|
+
import { join as join14 } from "path";
|
|
23021
23029
|
function getLockfilePath(wrapsDir) {
|
|
23022
|
-
return
|
|
23030
|
+
return join14(wrapsDir, ".wraps", "lockfile.json");
|
|
23023
23031
|
}
|
|
23024
23032
|
async function loadLockfile(wrapsDir) {
|
|
23025
23033
|
const path3 = getLockfilePath(wrapsDir);
|
|
@@ -23042,7 +23050,7 @@ async function loadLockfile(wrapsDir) {
|
|
|
23042
23050
|
}
|
|
23043
23051
|
async function saveLockfile(wrapsDir, lockfile) {
|
|
23044
23052
|
const path3 = getLockfilePath(wrapsDir);
|
|
23045
|
-
const dir =
|
|
23053
|
+
const dir = join14(path3, "..");
|
|
23046
23054
|
await mkdir5(dir, { recursive: true });
|
|
23047
23055
|
await writeFile7(path3, JSON.stringify(lockfile, null, 2), "utf-8");
|
|
23048
23056
|
}
|
|
@@ -23052,8 +23060,8 @@ init_output();
|
|
|
23052
23060
|
async function templatesPush(options) {
|
|
23053
23061
|
const startTime = Date.now();
|
|
23054
23062
|
const cwd = process.cwd();
|
|
23055
|
-
const wrapsDir =
|
|
23056
|
-
const configPath =
|
|
23063
|
+
const wrapsDir = join15(cwd, "wraps");
|
|
23064
|
+
const configPath = join15(wrapsDir, "wraps.config.ts");
|
|
23057
23065
|
if (!existsSync13(configPath)) {
|
|
23058
23066
|
throw errors.wrapsConfigNotFound();
|
|
23059
23067
|
}
|
|
@@ -23064,7 +23072,7 @@ async function templatesPush(options) {
|
|
|
23064
23072
|
progress.start("Loading configuration");
|
|
23065
23073
|
const config2 = await loadWrapsConfig(wrapsDir);
|
|
23066
23074
|
progress.succeed("Configuration loaded");
|
|
23067
|
-
const templatesDir =
|
|
23075
|
+
const templatesDir = join15(wrapsDir, config2.templatesDir || "./templates");
|
|
23068
23076
|
if (!existsSync13(templatesDir)) {
|
|
23069
23077
|
throw errors.wrapsConfigNotFound();
|
|
23070
23078
|
}
|
|
@@ -23083,7 +23091,7 @@ async function templatesPush(options) {
|
|
|
23083
23091
|
const compileErrors = [];
|
|
23084
23092
|
for (const file of templateFiles) {
|
|
23085
23093
|
const slug = file.replace(/\.tsx?$/, "");
|
|
23086
|
-
const filePath =
|
|
23094
|
+
const filePath = join15(templatesDir, file);
|
|
23087
23095
|
const source = await readFile6(filePath, "utf-8");
|
|
23088
23096
|
const sourceHash = sha256(source);
|
|
23089
23097
|
const localHashMatches = lockfile.templates[slug]?.localHash === sourceHash;
|
|
@@ -23225,10 +23233,10 @@ async function compileTemplate(filePath, slug, source, sourceHash, wrapsDir) {
|
|
|
23225
23233
|
}
|
|
23226
23234
|
});
|
|
23227
23235
|
const bundledCode = result.outputFiles[0].text;
|
|
23228
|
-
const projectRoot =
|
|
23229
|
-
const tmpDir =
|
|
23236
|
+
const projectRoot = join15(wrapsDir, "..");
|
|
23237
|
+
const tmpDir = join15(projectRoot, "node_modules", ".wraps-compiled");
|
|
23230
23238
|
await mkdir6(tmpDir, { recursive: true });
|
|
23231
|
-
const tmpPath =
|
|
23239
|
+
const tmpPath = join15(tmpDir, `${slug}.mjs`);
|
|
23232
23240
|
await writeFile8(tmpPath, bundledCode, "utf-8");
|
|
23233
23241
|
const mod = await import(tmpPath);
|
|
23234
23242
|
const Component = mod.default;
|
|
@@ -25534,7 +25542,7 @@ init_json_output();
|
|
|
25534
25542
|
init_output();
|
|
25535
25543
|
import { existsSync as existsSync14 } from "fs";
|
|
25536
25544
|
import { mkdir as mkdir7, readFile as readFile7, writeFile as writeFile9 } from "fs/promises";
|
|
25537
|
-
import { join as
|
|
25545
|
+
import { join as join16 } from "path";
|
|
25538
25546
|
import * as clack30 from "@clack/prompts";
|
|
25539
25547
|
import pc31 from "picocolors";
|
|
25540
25548
|
|
|
@@ -25925,7 +25933,7 @@ export default defineWorkflow({
|
|
|
25925
25933
|
async function workflowsInit(options) {
|
|
25926
25934
|
const startTime = Date.now();
|
|
25927
25935
|
const cwd = process.cwd();
|
|
25928
|
-
const workflowsDir =
|
|
25936
|
+
const workflowsDir = join16(cwd, "wraps", "workflows");
|
|
25929
25937
|
if (!isJsonMode()) {
|
|
25930
25938
|
clack30.intro(pc31.bold("Workflows as Code"));
|
|
25931
25939
|
}
|
|
@@ -25944,7 +25952,7 @@ async function workflowsInit(options) {
|
|
|
25944
25952
|
}
|
|
25945
25953
|
progress.start("Creating wraps/workflows/ directory");
|
|
25946
25954
|
await mkdir7(workflowsDir, { recursive: true });
|
|
25947
|
-
const configPath =
|
|
25955
|
+
const configPath = join16(cwd, "wraps", "wraps.config.ts");
|
|
25948
25956
|
if (existsSync14(configPath)) {
|
|
25949
25957
|
const configContent = await readFile7(configPath, "utf-8");
|
|
25950
25958
|
if (!configContent.includes("workflowsDir")) {
|
|
@@ -25962,7 +25970,7 @@ async function workflowsInit(options) {
|
|
|
25962
25970
|
}
|
|
25963
25971
|
const filesCreated = [];
|
|
25964
25972
|
if (!options.noExample) {
|
|
25965
|
-
const examplePath =
|
|
25973
|
+
const examplePath = join16(workflowsDir, "welcome.ts");
|
|
25966
25974
|
if (!existsSync14(examplePath) || options.force) {
|
|
25967
25975
|
await writeFile9(examplePath, EXAMPLE_WORKFLOW, "utf-8");
|
|
25968
25976
|
filesCreated.push("wraps/workflows/welcome.ts");
|
|
@@ -26046,7 +26054,7 @@ export default defineConfig({
|
|
|
26046
26054
|
init_esm_shims();
|
|
26047
26055
|
init_events();
|
|
26048
26056
|
import { existsSync as existsSync16 } from "fs";
|
|
26049
|
-
import { join as
|
|
26057
|
+
import { join as join18 } from "path";
|
|
26050
26058
|
import * as clack31 from "@clack/prompts";
|
|
26051
26059
|
import pc32 from "picocolors";
|
|
26052
26060
|
|
|
@@ -26267,7 +26275,7 @@ init_esm_shims();
|
|
|
26267
26275
|
import { createHash as createHash2 } from "crypto";
|
|
26268
26276
|
import { existsSync as existsSync15 } from "fs";
|
|
26269
26277
|
import { mkdir as mkdir8, readdir as readdir4, readFile as readFile8, writeFile as writeFile10 } from "fs/promises";
|
|
26270
|
-
import { basename, join as
|
|
26278
|
+
import { basename, join as join17 } from "path";
|
|
26271
26279
|
async function discoverWorkflows(dir, filter) {
|
|
26272
26280
|
if (!existsSync15(dir)) {
|
|
26273
26281
|
return [];
|
|
@@ -26292,7 +26300,7 @@ async function parseWorkflowTs(filePath, wrapsDir) {
|
|
|
26292
26300
|
const source = await readFile8(filePath, "utf-8");
|
|
26293
26301
|
const sourceHash = createHash2("sha256").update(source).digest("hex");
|
|
26294
26302
|
const slug = basename(filePath, ".ts");
|
|
26295
|
-
const shimDir =
|
|
26303
|
+
const shimDir = join17(wrapsDir, ".wraps", "_shims");
|
|
26296
26304
|
await mkdir8(shimDir, { recursive: true });
|
|
26297
26305
|
const clientShimContent = `
|
|
26298
26306
|
// Identity functions for workflow definitions
|
|
@@ -26521,7 +26529,7 @@ function durationToSeconds(duration) {
|
|
|
26521
26529
|
}
|
|
26522
26530
|
`;
|
|
26523
26531
|
await writeFile10(
|
|
26524
|
-
|
|
26532
|
+
join17(shimDir, "wraps-client-shim.mjs"),
|
|
26525
26533
|
clientShimContent,
|
|
26526
26534
|
"utf-8"
|
|
26527
26535
|
);
|
|
@@ -26533,13 +26541,13 @@ function durationToSeconds(duration) {
|
|
|
26533
26541
|
platform: "node",
|
|
26534
26542
|
target: "node20",
|
|
26535
26543
|
alias: {
|
|
26536
|
-
"@wraps.dev/client":
|
|
26544
|
+
"@wraps.dev/client": join17(shimDir, "wraps-client-shim.mjs")
|
|
26537
26545
|
}
|
|
26538
26546
|
});
|
|
26539
26547
|
const bundledCode = result.outputFiles[0].text;
|
|
26540
|
-
const tmpDir =
|
|
26548
|
+
const tmpDir = join17(wrapsDir, ".wraps", "_workflows");
|
|
26541
26549
|
await mkdir8(tmpDir, { recursive: true });
|
|
26542
|
-
const tmpPath =
|
|
26550
|
+
const tmpPath = join17(tmpDir, `${slug}.mjs`);
|
|
26543
26551
|
await writeFile10(tmpPath, bundledCode, "utf-8");
|
|
26544
26552
|
const mod = await import(`${tmpPath}?t=${Date.now()}`);
|
|
26545
26553
|
const definition = mod.default;
|
|
@@ -26892,8 +26900,8 @@ init_output();
|
|
|
26892
26900
|
async function workflowsPush(options) {
|
|
26893
26901
|
const startTime = Date.now();
|
|
26894
26902
|
const cwd = process.cwd();
|
|
26895
|
-
const wrapsDir =
|
|
26896
|
-
const configPath =
|
|
26903
|
+
const wrapsDir = join18(cwd, "wraps");
|
|
26904
|
+
const configPath = join18(wrapsDir, "wraps.config.ts");
|
|
26897
26905
|
if (!existsSync16(configPath)) {
|
|
26898
26906
|
throw errors.wrapsConfigNotFound();
|
|
26899
26907
|
}
|
|
@@ -26904,7 +26912,7 @@ async function workflowsPush(options) {
|
|
|
26904
26912
|
progress.start("Loading configuration");
|
|
26905
26913
|
const config2 = await loadWrapsConfig(wrapsDir);
|
|
26906
26914
|
progress.succeed("Configuration loaded");
|
|
26907
|
-
const workflowsDir =
|
|
26915
|
+
const workflowsDir = join18(wrapsDir, config2.workflowsDir || "./workflows");
|
|
26908
26916
|
if (!existsSync16(workflowsDir)) {
|
|
26909
26917
|
if (isJsonMode()) {
|
|
26910
26918
|
jsonSuccess("email.workflows.push", {
|
|
@@ -26931,7 +26939,7 @@ async function workflowsPush(options) {
|
|
|
26931
26939
|
return;
|
|
26932
26940
|
}
|
|
26933
26941
|
const lockfile = await loadLockfile(wrapsDir);
|
|
26934
|
-
const templatesDir =
|
|
26942
|
+
const templatesDir = join18(wrapsDir, config2.templatesDir || "./templates");
|
|
26935
26943
|
let localTemplateSlugs;
|
|
26936
26944
|
if (existsSync16(templatesDir)) {
|
|
26937
26945
|
const templateFiles = await discoverTemplates(templatesDir);
|
|
@@ -26945,7 +26953,7 @@ async function workflowsPush(options) {
|
|
|
26945
26953
|
const validationErrors = [];
|
|
26946
26954
|
for (const file of workflowFiles) {
|
|
26947
26955
|
const slug = file.replace(/\.ts$/, "");
|
|
26948
|
-
const filePath =
|
|
26956
|
+
const filePath = join18(workflowsDir, file);
|
|
26949
26957
|
progress.start(`Processing ${pc32.cyan(slug)}`);
|
|
26950
26958
|
try {
|
|
26951
26959
|
const parsed = await parseWorkflowTs(filePath, wrapsDir);
|
|
@@ -27264,7 +27272,7 @@ async function pushToAPI2(workflows, token, progress, options) {
|
|
|
27264
27272
|
init_esm_shims();
|
|
27265
27273
|
init_events();
|
|
27266
27274
|
import { existsSync as existsSync17 } from "fs";
|
|
27267
|
-
import { join as
|
|
27275
|
+
import { join as join19 } from "path";
|
|
27268
27276
|
import * as clack32 from "@clack/prompts";
|
|
27269
27277
|
import pc33 from "picocolors";
|
|
27270
27278
|
init_errors();
|
|
@@ -27273,8 +27281,8 @@ init_output();
|
|
|
27273
27281
|
async function workflowsValidate(options) {
|
|
27274
27282
|
const startTime = Date.now();
|
|
27275
27283
|
const cwd = process.cwd();
|
|
27276
|
-
const wrapsDir =
|
|
27277
|
-
const configPath =
|
|
27284
|
+
const wrapsDir = join19(cwd, "wraps");
|
|
27285
|
+
const configPath = join19(wrapsDir, "wraps.config.ts");
|
|
27278
27286
|
if (!existsSync17(configPath)) {
|
|
27279
27287
|
throw errors.wrapsConfigNotFound();
|
|
27280
27288
|
}
|
|
@@ -27285,7 +27293,7 @@ async function workflowsValidate(options) {
|
|
|
27285
27293
|
progress.start("Loading configuration");
|
|
27286
27294
|
const config2 = await loadWrapsConfig(wrapsDir);
|
|
27287
27295
|
progress.succeed("Configuration loaded");
|
|
27288
|
-
const workflowsDir =
|
|
27296
|
+
const workflowsDir = join19(wrapsDir, config2.workflowsDir || "./workflows");
|
|
27289
27297
|
if (!existsSync17(workflowsDir)) {
|
|
27290
27298
|
if (isJsonMode()) {
|
|
27291
27299
|
jsonSuccess("email.workflows.validate", { workflows: [], errors: [] });
|
|
@@ -27303,7 +27311,7 @@ async function workflowsValidate(options) {
|
|
|
27303
27311
|
}
|
|
27304
27312
|
return;
|
|
27305
27313
|
}
|
|
27306
|
-
const templatesDir =
|
|
27314
|
+
const templatesDir = join19(wrapsDir, config2.templatesDir || "./templates");
|
|
27307
27315
|
let localTemplateSlugs;
|
|
27308
27316
|
if (existsSync17(templatesDir)) {
|
|
27309
27317
|
const templateFiles = await discoverTemplates(templatesDir);
|
|
@@ -27315,7 +27323,7 @@ async function workflowsValidate(options) {
|
|
|
27315
27323
|
const parseErrors = [];
|
|
27316
27324
|
for (const file of workflowFiles) {
|
|
27317
27325
|
const slug = file.replace(/\.ts$/, "");
|
|
27318
|
-
const filePath =
|
|
27326
|
+
const filePath = join19(workflowsDir, file);
|
|
27319
27327
|
progress.start(`Validating ${pc33.cyan(slug)}`);
|
|
27320
27328
|
try {
|
|
27321
27329
|
const parsed = await parseWorkflowTs(filePath, wrapsDir);
|
|
@@ -29220,7 +29228,7 @@ import pc39 from "picocolors";
|
|
|
29220
29228
|
init_esm_shims();
|
|
29221
29229
|
import crypto from "crypto";
|
|
29222
29230
|
import path2 from "path";
|
|
29223
|
-
import { fileURLToPath as
|
|
29231
|
+
import { fileURLToPath as fileURLToPath5 } from "url";
|
|
29224
29232
|
import express from "express";
|
|
29225
29233
|
import { createHttpTerminator } from "http-terminator";
|
|
29226
29234
|
|
|
@@ -31744,7 +31752,7 @@ function createUserRouter(config2) {
|
|
|
31744
31752
|
}
|
|
31745
31753
|
|
|
31746
31754
|
// src/console/server.ts
|
|
31747
|
-
var __dirname2 = path2.dirname(
|
|
31755
|
+
var __dirname2 = path2.dirname(fileURLToPath5(import.meta.url));
|
|
31748
31756
|
async function startConsoleServer(config2) {
|
|
31749
31757
|
const app = express();
|
|
31750
31758
|
const authToken = crypto.randomBytes(32).toString("hex");
|
|
@@ -36328,7 +36336,7 @@ async function telemetryStatus() {
|
|
|
36328
36336
|
// src/commands/workflow/init.ts
|
|
36329
36337
|
init_esm_shims();
|
|
36330
36338
|
import { existsSync as existsSync18, mkdirSync as mkdirSync2, writeFileSync } from "fs";
|
|
36331
|
-
import { join as
|
|
36339
|
+
import { join as join20 } from "path";
|
|
36332
36340
|
import * as clack49 from "@clack/prompts";
|
|
36333
36341
|
import pc52 from "picocolors";
|
|
36334
36342
|
var EXAMPLE_CASCADE_WORKFLOW = `import {
|
|
@@ -36426,14 +36434,14 @@ export default defineConfig({
|
|
|
36426
36434
|
`;
|
|
36427
36435
|
async function workflowInit(options = {}) {
|
|
36428
36436
|
clack49.intro(pc52.bgCyan(pc52.black(" wraps workflow init ")));
|
|
36429
|
-
const wrapsDir =
|
|
36430
|
-
const workflowsDir =
|
|
36431
|
-
const configPath =
|
|
36437
|
+
const wrapsDir = join20(process.cwd(), "wraps");
|
|
36438
|
+
const workflowsDir = join20(wrapsDir, "workflows");
|
|
36439
|
+
const configPath = join20(wrapsDir, "wraps.config.ts");
|
|
36432
36440
|
if (existsSync18(workflowsDir)) {
|
|
36433
36441
|
clack49.log.info(
|
|
36434
36442
|
`Workflows directory already exists at ${pc52.cyan("wraps/workflows/")}`
|
|
36435
36443
|
);
|
|
36436
|
-
const files = existsSync18(
|
|
36444
|
+
const files = existsSync18(join20(workflowsDir, "cart-recovery.ts")) || existsSync18(join20(workflowsDir, "welcome-sequence.ts"));
|
|
36437
36445
|
if (files && !options.yes) {
|
|
36438
36446
|
const shouldContinue = await clack49.confirm({
|
|
36439
36447
|
message: "Example files may already exist. Overwrite them?",
|
|
@@ -36454,12 +36462,12 @@ async function workflowInit(options = {}) {
|
|
|
36454
36462
|
s.stop("Created wraps/workflows/");
|
|
36455
36463
|
s.start("Scaffolding example workflows...");
|
|
36456
36464
|
writeFileSync(
|
|
36457
|
-
|
|
36465
|
+
join20(workflowsDir, "cart-recovery.ts"),
|
|
36458
36466
|
EXAMPLE_CASCADE_WORKFLOW,
|
|
36459
36467
|
"utf-8"
|
|
36460
36468
|
);
|
|
36461
36469
|
writeFileSync(
|
|
36462
|
-
|
|
36470
|
+
join20(workflowsDir, "welcome-sequence.ts"),
|
|
36463
36471
|
EXAMPLE_WELCOME_WORKFLOW,
|
|
36464
36472
|
"utf-8"
|
|
36465
36473
|
);
|
|
@@ -36564,10 +36572,10 @@ if (nodeMajorVersion < 20) {
|
|
|
36564
36572
|
console.error("");
|
|
36565
36573
|
process.exit(1);
|
|
36566
36574
|
}
|
|
36567
|
-
var __filename2 =
|
|
36568
|
-
var __dirname3 =
|
|
36575
|
+
var __filename2 = fileURLToPath6(import.meta.url);
|
|
36576
|
+
var __dirname3 = dirname5(__filename2);
|
|
36569
36577
|
var packageJson = JSON.parse(
|
|
36570
|
-
readFileSync3(
|
|
36578
|
+
readFileSync3(join21(__dirname3, "../package.json"), "utf-8")
|
|
36571
36579
|
);
|
|
36572
36580
|
var VERSION = packageJson.version;
|
|
36573
36581
|
setupTabCompletion();
|