@tanstack/cli 0.0.6 → 0.0.8
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/bin.cjs +15 -7
- package/dist/bin.mjs +11 -3
- package/dist/fetch-CbFFGJEw.cjs +3 -0
- package/dist/fetch-DG5dLrsb.cjs +522 -0
- package/dist/fetch-DhlVXS6S.mjs +390 -0
- package/dist/fetch-I_OVg8JX.mjs +3 -0
- package/dist/index.cjs +23 -22
- package/dist/index.mjs +2 -1
- package/dist/{template-CkAkdP8n.mjs → template-Szi7-AZJ.mjs} +53 -396
- package/dist/{template-Cup47s9h.cjs → template-lWrIZhCQ.cjs} +53 -522
- package/package.json +1 -1
- package/src/api/fetch.ts +31 -2
- package/src/commands/create.ts +9 -2
- package/src/commands/mcp.ts +9 -1
- package/src/engine/compile.ts +18 -0
- package/src/templates/base.ts +11 -19
|
@@ -25,16 +25,15 @@ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__ge
|
|
|
25
25
|
}) : target, mod));
|
|
26
26
|
|
|
27
27
|
//#endregion
|
|
28
|
+
const require_fetch = require('./fetch-DG5dLrsb.cjs');
|
|
28
29
|
let ejs = require("ejs");
|
|
29
30
|
let node_fs_promises = require("node:fs/promises");
|
|
30
31
|
let node_fs = require("node:fs");
|
|
31
32
|
let node_path = require("node:path");
|
|
32
|
-
let zod = require("zod");
|
|
33
33
|
let ignore = require("ignore");
|
|
34
34
|
ignore = __toESM(ignore);
|
|
35
35
|
let parse_gitignore = require("parse-gitignore");
|
|
36
36
|
parse_gitignore = __toESM(parse_gitignore);
|
|
37
|
-
let node_os = require("node:os");
|
|
38
37
|
|
|
39
38
|
//#region src/engine/template.ts
|
|
40
39
|
/**
|
|
@@ -352,16 +351,16 @@ function generateEntryClient(_options, entryClientInits) {
|
|
|
352
351
|
function generateRootRoute(options, rootProviders, devtoolsPlugins) {
|
|
353
352
|
const lines = [];
|
|
354
353
|
const hasHeader = options.chosenIntegrations.length > 0;
|
|
355
|
-
|
|
356
|
-
text: `import
|
|
354
|
+
lines.push({
|
|
355
|
+
text: `import { HeadContent, Scripts, createRootRoute } from '@tanstack/react-router'`,
|
|
357
356
|
integrationId: "base"
|
|
358
357
|
});
|
|
359
358
|
lines.push({
|
|
360
|
-
text: `import {
|
|
359
|
+
text: `import { TanStackDevtools } from '@tanstack/react-devtools'`,
|
|
361
360
|
integrationId: "base"
|
|
362
361
|
});
|
|
363
362
|
lines.push({
|
|
364
|
-
text: `import {
|
|
363
|
+
text: `import { TanStackRouterDevtoolsPanel } from '@tanstack/react-router-devtools'`,
|
|
365
364
|
integrationId: "base"
|
|
366
365
|
});
|
|
367
366
|
lines.push({
|
|
@@ -386,24 +385,6 @@ function generateRootRoute(options, rootProviders, devtoolsPlugins) {
|
|
|
386
385
|
integrationId: devtools.integrationId
|
|
387
386
|
});
|
|
388
387
|
}
|
|
389
|
-
if (devtoolsPlugins.length > 0) {
|
|
390
|
-
lines.push({
|
|
391
|
-
text: "",
|
|
392
|
-
integrationId: "base"
|
|
393
|
-
});
|
|
394
|
-
lines.push({
|
|
395
|
-
text: `const devtoolsPlugins = [`,
|
|
396
|
-
integrationId: "base"
|
|
397
|
-
});
|
|
398
|
-
for (const devtools of devtoolsPlugins) lines.push({
|
|
399
|
-
text: ` ${devtools.jsName},`,
|
|
400
|
-
integrationId: devtools.integrationId
|
|
401
|
-
});
|
|
402
|
-
lines.push({
|
|
403
|
-
text: `]`,
|
|
404
|
-
integrationId: "base"
|
|
405
|
-
});
|
|
406
|
-
}
|
|
407
388
|
lines.push({
|
|
408
389
|
text: "",
|
|
409
390
|
integrationId: "base"
|
|
@@ -501,23 +482,33 @@ function generateRootRoute(options, rootProviders, devtoolsPlugins) {
|
|
|
501
482
|
integrationId: "base"
|
|
502
483
|
});
|
|
503
484
|
lines.push({
|
|
504
|
-
text: `${currentIndent}<
|
|
485
|
+
text: `${currentIndent}<TanStackDevtools`,
|
|
486
|
+
integrationId: "base"
|
|
487
|
+
});
|
|
488
|
+
lines.push({
|
|
489
|
+
text: `${currentIndent} config={{ position: 'bottom-right' }}`,
|
|
490
|
+
integrationId: "base"
|
|
491
|
+
});
|
|
492
|
+
lines.push({
|
|
493
|
+
text: `${currentIndent} plugins={[`,
|
|
494
|
+
integrationId: "base"
|
|
495
|
+
});
|
|
496
|
+
lines.push({
|
|
497
|
+
text: `${currentIndent} { name: 'TanStack Router', render: <TanStackRouterDevtoolsPanel /> },`,
|
|
498
|
+
integrationId: "base"
|
|
499
|
+
});
|
|
500
|
+
for (const devtools of devtoolsPlugins) lines.push({
|
|
501
|
+
text: `${currentIndent} ${devtools.jsName},`,
|
|
502
|
+
integrationId: devtools.integrationId
|
|
503
|
+
});
|
|
504
|
+
lines.push({
|
|
505
|
+
text: `${currentIndent} ]}`,
|
|
506
|
+
integrationId: "base"
|
|
507
|
+
});
|
|
508
|
+
lines.push({
|
|
509
|
+
text: `${currentIndent}/>`,
|
|
505
510
|
integrationId: "base"
|
|
506
511
|
});
|
|
507
|
-
if (devtoolsPlugins.length > 0) {
|
|
508
|
-
lines.push({
|
|
509
|
-
text: `${currentIndent}{devtoolsPlugins.map((plugin, i) => (`,
|
|
510
|
-
integrationId: "base"
|
|
511
|
-
});
|
|
512
|
-
lines.push({
|
|
513
|
-
text: `${currentIndent} <React.Fragment key={i}>{plugin.render}</React.Fragment>`,
|
|
514
|
-
integrationId: "base"
|
|
515
|
-
});
|
|
516
|
-
lines.push({
|
|
517
|
-
text: `${currentIndent}))}`,
|
|
518
|
-
integrationId: "base"
|
|
519
|
-
});
|
|
520
|
-
}
|
|
521
512
|
for (const provider of [...rootProviders].reverse()) {
|
|
522
513
|
currentIndent = currentIndent.slice(0, -2);
|
|
523
514
|
lines.push({
|
|
@@ -1491,6 +1482,7 @@ function buildPackageJson(options, packages) {
|
|
|
1491
1482
|
dependencies: {
|
|
1492
1483
|
"@tanstack/react-router": "^1.132.0",
|
|
1493
1484
|
"@tanstack/react-router-devtools": "^1.132.0",
|
|
1485
|
+
"@tanstack/react-devtools": "^0.9.2",
|
|
1494
1486
|
"@tanstack/react-start": "^1.132.0",
|
|
1495
1487
|
react: "^19.2.0",
|
|
1496
1488
|
"react-dom": "^19.2.0",
|
|
@@ -1564,14 +1556,28 @@ function compile(options) {
|
|
|
1564
1556
|
for (const [path, { content }] of files) outputFiles[path] = content;
|
|
1565
1557
|
outputFiles["package.json"] = buildPackageJson(options, packages);
|
|
1566
1558
|
const seenEnvVars = /* @__PURE__ */ new Set();
|
|
1559
|
+
const uniqueEnvVars = envVars.filter((v) => {
|
|
1560
|
+
if (seenEnvVars.has(v.name)) return false;
|
|
1561
|
+
seenEnvVars.add(v.name);
|
|
1562
|
+
return true;
|
|
1563
|
+
});
|
|
1564
|
+
if (uniqueEnvVars.length > 0) {
|
|
1565
|
+
const envLines = [
|
|
1566
|
+
"# Environment Variables",
|
|
1567
|
+
"# Copy this file to .env.local and fill in your values",
|
|
1568
|
+
""
|
|
1569
|
+
];
|
|
1570
|
+
for (const v of uniqueEnvVars) {
|
|
1571
|
+
envLines.push(`# ${v.description}${v.required ? " (required)" : ""}`);
|
|
1572
|
+
envLines.push(`${v.name}=${v.example || ""}`);
|
|
1573
|
+
envLines.push("");
|
|
1574
|
+
}
|
|
1575
|
+
outputFiles[".env.example"] = envLines.join("\n");
|
|
1576
|
+
}
|
|
1567
1577
|
return {
|
|
1568
1578
|
files: outputFiles,
|
|
1569
1579
|
packages,
|
|
1570
|
-
envVars:
|
|
1571
|
-
if (seenEnvVars.has(v.name)) return false;
|
|
1572
|
-
seenEnvVars.add(v.name);
|
|
1573
|
-
return true;
|
|
1574
|
-
}),
|
|
1580
|
+
envVars: uniqueEnvVars,
|
|
1575
1581
|
warnings
|
|
1576
1582
|
};
|
|
1577
1583
|
}
|
|
@@ -1820,355 +1826,6 @@ async function readConfigFile(targetDir) {
|
|
|
1820
1826
|
}
|
|
1821
1827
|
}
|
|
1822
1828
|
|
|
1823
|
-
//#endregion
|
|
1824
|
-
//#region src/engine/types.ts
|
|
1825
|
-
const CategorySchema = zod.z.enum([
|
|
1826
|
-
"tanstack",
|
|
1827
|
-
"database",
|
|
1828
|
-
"orm",
|
|
1829
|
-
"auth",
|
|
1830
|
-
"deploy",
|
|
1831
|
-
"tooling",
|
|
1832
|
-
"monitoring",
|
|
1833
|
-
"api",
|
|
1834
|
-
"i18n",
|
|
1835
|
-
"cms",
|
|
1836
|
-
"other"
|
|
1837
|
-
]);
|
|
1838
|
-
const IntegrationTypeSchema = zod.z.enum([
|
|
1839
|
-
"integration",
|
|
1840
|
-
"example",
|
|
1841
|
-
"toolchain",
|
|
1842
|
-
"deployment"
|
|
1843
|
-
]);
|
|
1844
|
-
const IntegrationPhaseSchema = zod.z.enum([
|
|
1845
|
-
"setup",
|
|
1846
|
-
"integration",
|
|
1847
|
-
"example"
|
|
1848
|
-
]);
|
|
1849
|
-
const RouterModeSchema = zod.z.enum(["file-router", "code-router"]);
|
|
1850
|
-
const SelectOptionSchema = zod.z.object({
|
|
1851
|
-
type: zod.z.literal("select"),
|
|
1852
|
-
label: zod.z.string(),
|
|
1853
|
-
description: zod.z.string().optional(),
|
|
1854
|
-
default: zod.z.string(),
|
|
1855
|
-
options: zod.z.array(zod.z.object({
|
|
1856
|
-
value: zod.z.string(),
|
|
1857
|
-
label: zod.z.string()
|
|
1858
|
-
}))
|
|
1859
|
-
});
|
|
1860
|
-
const BooleanOptionSchema = zod.z.object({
|
|
1861
|
-
type: zod.z.literal("boolean"),
|
|
1862
|
-
label: zod.z.string(),
|
|
1863
|
-
description: zod.z.string().optional(),
|
|
1864
|
-
default: zod.z.boolean()
|
|
1865
|
-
});
|
|
1866
|
-
const StringOptionSchema = zod.z.object({
|
|
1867
|
-
type: zod.z.literal("string"),
|
|
1868
|
-
label: zod.z.string(),
|
|
1869
|
-
description: zod.z.string().optional(),
|
|
1870
|
-
default: zod.z.string()
|
|
1871
|
-
});
|
|
1872
|
-
const IntegrationOptionSchema = zod.z.discriminatedUnion("type", [
|
|
1873
|
-
SelectOptionSchema,
|
|
1874
|
-
BooleanOptionSchema,
|
|
1875
|
-
StringOptionSchema
|
|
1876
|
-
]);
|
|
1877
|
-
const IntegrationOptionsSchema = zod.z.record(zod.z.string(), IntegrationOptionSchema);
|
|
1878
|
-
const HookTypeSchema = zod.z.enum([
|
|
1879
|
-
"header-user",
|
|
1880
|
-
"provider",
|
|
1881
|
-
"root-provider",
|
|
1882
|
-
"layout",
|
|
1883
|
-
"vite-plugin",
|
|
1884
|
-
"devtools",
|
|
1885
|
-
"entry-client"
|
|
1886
|
-
]);
|
|
1887
|
-
const HookSchema = zod.z.object({
|
|
1888
|
-
type: HookTypeSchema.optional(),
|
|
1889
|
-
path: zod.z.string().optional(),
|
|
1890
|
-
jsName: zod.z.string().optional(),
|
|
1891
|
-
import: zod.z.string().optional(),
|
|
1892
|
-
code: zod.z.string().optional()
|
|
1893
|
-
});
|
|
1894
|
-
const RouteSchema = zod.z.object({
|
|
1895
|
-
url: zod.z.string().optional(),
|
|
1896
|
-
name: zod.z.string().optional(),
|
|
1897
|
-
icon: zod.z.string().optional(),
|
|
1898
|
-
path: zod.z.string(),
|
|
1899
|
-
jsName: zod.z.string(),
|
|
1900
|
-
children: zod.z.array(zod.z.lazy(() => RouteSchema)).optional()
|
|
1901
|
-
});
|
|
1902
|
-
const EnvVarSchema = zod.z.object({
|
|
1903
|
-
name: zod.z.string(),
|
|
1904
|
-
description: zod.z.string(),
|
|
1905
|
-
required: zod.z.boolean().optional(),
|
|
1906
|
-
example: zod.z.string().optional()
|
|
1907
|
-
});
|
|
1908
|
-
const CommandSchema = zod.z.object({
|
|
1909
|
-
command: zod.z.string(),
|
|
1910
|
-
args: zod.z.array(zod.z.string()).optional()
|
|
1911
|
-
});
|
|
1912
|
-
const IntegrationInfoSchema = zod.z.object({
|
|
1913
|
-
id: zod.z.string().optional(),
|
|
1914
|
-
name: zod.z.string(),
|
|
1915
|
-
description: zod.z.string(),
|
|
1916
|
-
author: zod.z.string().optional(),
|
|
1917
|
-
version: zod.z.string().optional(),
|
|
1918
|
-
link: zod.z.string().optional(),
|
|
1919
|
-
license: zod.z.string().optional(),
|
|
1920
|
-
warning: zod.z.string().optional(),
|
|
1921
|
-
type: IntegrationTypeSchema,
|
|
1922
|
-
phase: IntegrationPhaseSchema,
|
|
1923
|
-
category: CategorySchema.optional(),
|
|
1924
|
-
modes: zod.z.array(RouterModeSchema),
|
|
1925
|
-
priority: zod.z.number().optional(),
|
|
1926
|
-
default: zod.z.boolean().optional(),
|
|
1927
|
-
requiresTailwind: zod.z.boolean().optional(),
|
|
1928
|
-
demoRequiresTailwind: zod.z.boolean().optional(),
|
|
1929
|
-
dependsOn: zod.z.array(zod.z.string()).optional(),
|
|
1930
|
-
exclusive: zod.z.array(zod.z.string()).optional(),
|
|
1931
|
-
partnerId: zod.z.string().optional(),
|
|
1932
|
-
options: IntegrationOptionsSchema.optional(),
|
|
1933
|
-
hooks: zod.z.array(HookSchema).optional(),
|
|
1934
|
-
routes: zod.z.array(RouteSchema).optional(),
|
|
1935
|
-
packageAdditions: zod.z.object({
|
|
1936
|
-
dependencies: zod.z.record(zod.z.string(), zod.z.string()).optional(),
|
|
1937
|
-
devDependencies: zod.z.record(zod.z.string(), zod.z.string()).optional(),
|
|
1938
|
-
scripts: zod.z.record(zod.z.string(), zod.z.string()).optional()
|
|
1939
|
-
}).optional(),
|
|
1940
|
-
shadcnComponents: zod.z.array(zod.z.string()).optional(),
|
|
1941
|
-
gitignorePatterns: zod.z.array(zod.z.string()).optional(),
|
|
1942
|
-
envVars: zod.z.array(EnvVarSchema).optional(),
|
|
1943
|
-
command: CommandSchema.optional(),
|
|
1944
|
-
integrationSpecialSteps: zod.z.array(zod.z.string()).optional(),
|
|
1945
|
-
createSpecialSteps: zod.z.array(zod.z.string()).optional(),
|
|
1946
|
-
postInitSpecialSteps: zod.z.array(zod.z.string()).optional(),
|
|
1947
|
-
smallLogo: zod.z.string().optional(),
|
|
1948
|
-
logo: zod.z.string().optional(),
|
|
1949
|
-
readme: zod.z.string().optional()
|
|
1950
|
-
});
|
|
1951
|
-
const IntegrationCompiledSchema = IntegrationInfoSchema.extend({
|
|
1952
|
-
id: zod.z.string(),
|
|
1953
|
-
files: zod.z.record(zod.z.string(), zod.z.string()),
|
|
1954
|
-
deletedFiles: zod.z.array(zod.z.string()).optional()
|
|
1955
|
-
});
|
|
1956
|
-
const CustomTemplateInfoSchema = zod.z.object({
|
|
1957
|
-
id: zod.z.string().optional(),
|
|
1958
|
-
name: zod.z.string(),
|
|
1959
|
-
description: zod.z.string(),
|
|
1960
|
-
framework: zod.z.string(),
|
|
1961
|
-
mode: RouterModeSchema,
|
|
1962
|
-
typescript: zod.z.boolean(),
|
|
1963
|
-
tailwind: zod.z.boolean(),
|
|
1964
|
-
integrations: zod.z.array(zod.z.string()),
|
|
1965
|
-
integrationOptions: zod.z.record(zod.z.string(), zod.z.record(zod.z.string(), zod.z.unknown())).optional(),
|
|
1966
|
-
banner: zod.z.string().optional()
|
|
1967
|
-
});
|
|
1968
|
-
const CustomTemplateCompiledSchema = CustomTemplateInfoSchema.extend({ id: zod.z.string() });
|
|
1969
|
-
const ManifestIntegrationSchema = zod.z.object({
|
|
1970
|
-
id: zod.z.string(),
|
|
1971
|
-
name: zod.z.string(),
|
|
1972
|
-
description: zod.z.string(),
|
|
1973
|
-
type: IntegrationTypeSchema,
|
|
1974
|
-
category: CategorySchema.optional(),
|
|
1975
|
-
modes: zod.z.array(RouterModeSchema),
|
|
1976
|
-
dependsOn: zod.z.array(zod.z.string()).optional(),
|
|
1977
|
-
exclusive: zod.z.array(zod.z.string()).optional(),
|
|
1978
|
-
partnerId: zod.z.string().optional(),
|
|
1979
|
-
hasOptions: zod.z.boolean().optional(),
|
|
1980
|
-
link: zod.z.string().optional(),
|
|
1981
|
-
color: zod.z.string().optional(),
|
|
1982
|
-
requiresTailwind: zod.z.boolean().optional(),
|
|
1983
|
-
demoRequiresTailwind: zod.z.boolean().optional()
|
|
1984
|
-
});
|
|
1985
|
-
const ManifestCustomTemplateSchema = zod.z.object({
|
|
1986
|
-
id: zod.z.string(),
|
|
1987
|
-
name: zod.z.string(),
|
|
1988
|
-
description: zod.z.string(),
|
|
1989
|
-
banner: zod.z.string().optional(),
|
|
1990
|
-
icon: zod.z.string().optional(),
|
|
1991
|
-
features: zod.z.array(zod.z.string()).optional()
|
|
1992
|
-
});
|
|
1993
|
-
const ManifestSchema = zod.z.object({
|
|
1994
|
-
version: zod.z.string(),
|
|
1995
|
-
generated: zod.z.string(),
|
|
1996
|
-
integrations: zod.z.array(ManifestIntegrationSchema),
|
|
1997
|
-
customTemplates: zod.z.array(ManifestCustomTemplateSchema).optional()
|
|
1998
|
-
});
|
|
1999
|
-
|
|
2000
|
-
//#endregion
|
|
2001
|
-
//#region src/cache/index.ts
|
|
2002
|
-
const CACHE_DIR = (0, node_path.join)((0, node_os.homedir)(), ".tanstack", "cache");
|
|
2003
|
-
const DEFAULT_TTL_MS = 1440 * 60 * 1e3;
|
|
2004
|
-
function ensureCacheDir() {
|
|
2005
|
-
if (!(0, node_fs.existsSync)(CACHE_DIR)) (0, node_fs.mkdirSync)(CACHE_DIR, { recursive: true });
|
|
2006
|
-
}
|
|
2007
|
-
function getCachePath(key) {
|
|
2008
|
-
return (0, node_path.join)(CACHE_DIR, `${key.replace(/[^a-zA-Z0-9-_]/g, "_")}.json`);
|
|
2009
|
-
}
|
|
2010
|
-
function getCached(key) {
|
|
2011
|
-
const cachePath = getCachePath(key);
|
|
2012
|
-
if (!(0, node_fs.existsSync)(cachePath)) return null;
|
|
2013
|
-
try {
|
|
2014
|
-
const raw = (0, node_fs.readFileSync)(cachePath, "utf-8");
|
|
2015
|
-
const entry = JSON.parse(raw);
|
|
2016
|
-
if (Date.now() - entry.timestamp > entry.ttl) return null;
|
|
2017
|
-
return entry.data;
|
|
2018
|
-
} catch {
|
|
2019
|
-
return null;
|
|
2020
|
-
}
|
|
2021
|
-
}
|
|
2022
|
-
function setCache(key, data, ttlMs = DEFAULT_TTL_MS) {
|
|
2023
|
-
ensureCacheDir();
|
|
2024
|
-
const cachePath = getCachePath(key);
|
|
2025
|
-
const entry = {
|
|
2026
|
-
data,
|
|
2027
|
-
timestamp: Date.now(),
|
|
2028
|
-
ttl: ttlMs
|
|
2029
|
-
};
|
|
2030
|
-
(0, node_fs.writeFileSync)(cachePath, JSON.stringify(entry, null, 2), "utf-8");
|
|
2031
|
-
}
|
|
2032
|
-
async function fetchWithCache(key, fetcher, ttlMs = DEFAULT_TTL_MS) {
|
|
2033
|
-
const cached = getCached(key);
|
|
2034
|
-
if (cached !== null) return cached;
|
|
2035
|
-
const data = await fetcher();
|
|
2036
|
-
setCache(key, data, ttlMs);
|
|
2037
|
-
return data;
|
|
2038
|
-
}
|
|
2039
|
-
|
|
2040
|
-
//#endregion
|
|
2041
|
-
//#region src/api/fetch.ts
|
|
2042
|
-
const GITHUB_RAW_BASE = "https://raw.githubusercontent.com/TanStack/cli/main/integrations";
|
|
2043
|
-
const CACHE_TTL_MS = 3600 * 1e3;
|
|
2044
|
-
/**
|
|
2045
|
-
* Check if a path is a local directory
|
|
2046
|
-
*/
|
|
2047
|
-
function isLocalPath(path) {
|
|
2048
|
-
return path.startsWith("/") || path.startsWith("./") || path.startsWith("..");
|
|
2049
|
-
}
|
|
2050
|
-
/**
|
|
2051
|
-
* Fetch the integration manifest from GitHub or local path (with caching for remote)
|
|
2052
|
-
*/
|
|
2053
|
-
async function fetchManifest(baseUrl = GITHUB_RAW_BASE) {
|
|
2054
|
-
if (isLocalPath(baseUrl)) {
|
|
2055
|
-
const manifestPath = (0, node_path.join)(baseUrl, "manifest.json");
|
|
2056
|
-
if (!(0, node_fs.existsSync)(manifestPath)) throw new Error(`Manifest not found at ${manifestPath}`);
|
|
2057
|
-
const data = JSON.parse((0, node_fs.readFileSync)(manifestPath, "utf-8"));
|
|
2058
|
-
return ManifestSchema.parse(data);
|
|
2059
|
-
}
|
|
2060
|
-
return fetchWithCache(`manifest_${baseUrl.replace(/[^a-zA-Z0-9]/g, "_")}`, async () => {
|
|
2061
|
-
const url = `${baseUrl}/manifest.json`;
|
|
2062
|
-
const response = await fetch(url);
|
|
2063
|
-
if (!response.ok) throw new Error(`Failed to fetch manifest: ${response.statusText}`);
|
|
2064
|
-
const data = await response.json();
|
|
2065
|
-
return ManifestSchema.parse(data);
|
|
2066
|
-
}, CACHE_TTL_MS);
|
|
2067
|
-
}
|
|
2068
|
-
/**
|
|
2069
|
-
* Fetch integration info.json from GitHub or local path (with caching for remote)
|
|
2070
|
-
*/
|
|
2071
|
-
async function fetchIntegrationInfo(integrationId, baseUrl = GITHUB_RAW_BASE) {
|
|
2072
|
-
if (isLocalPath(baseUrl)) {
|
|
2073
|
-
const infoPath = (0, node_path.join)(baseUrl, integrationId, "info.json");
|
|
2074
|
-
if (!(0, node_fs.existsSync)(infoPath)) throw new Error(`Integration info not found at ${infoPath}`);
|
|
2075
|
-
const data = JSON.parse((0, node_fs.readFileSync)(infoPath, "utf-8"));
|
|
2076
|
-
return IntegrationInfoSchema.parse(data);
|
|
2077
|
-
}
|
|
2078
|
-
return fetchWithCache(`integration_info_${integrationId}_${baseUrl.replace(/[^a-zA-Z0-9]/g, "_")}`, async () => {
|
|
2079
|
-
const url = `${baseUrl}/${integrationId}/info.json`;
|
|
2080
|
-
const response = await fetch(url);
|
|
2081
|
-
if (!response.ok) throw new Error(`Failed to fetch integration ${integrationId}: ${response.statusText}`);
|
|
2082
|
-
const data = await response.json();
|
|
2083
|
-
return IntegrationInfoSchema.parse(data);
|
|
2084
|
-
}, CACHE_TTL_MS);
|
|
2085
|
-
}
|
|
2086
|
-
/**
|
|
2087
|
-
* Recursively read all files from a directory
|
|
2088
|
-
*/
|
|
2089
|
-
function readDirRecursive(dir, basePath = "") {
|
|
2090
|
-
const files = {};
|
|
2091
|
-
if (!(0, node_fs.existsSync)(dir)) return files;
|
|
2092
|
-
for (const entry of (0, node_fs.readdirSync)(dir)) {
|
|
2093
|
-
const fullPath = (0, node_path.join)(dir, entry);
|
|
2094
|
-
const relativePath$1 = basePath ? `${basePath}/${entry}` : entry;
|
|
2095
|
-
if ((0, node_fs.statSync)(fullPath).isDirectory()) Object.assign(files, readDirRecursive(fullPath, relativePath$1));
|
|
2096
|
-
else files[relativePath$1] = (0, node_fs.readFileSync)(fullPath, "utf-8");
|
|
2097
|
-
}
|
|
2098
|
-
return files;
|
|
2099
|
-
}
|
|
2100
|
-
/**
|
|
2101
|
-
* Fetch all files for an integration from GitHub or local path (with caching for remote)
|
|
2102
|
-
*/
|
|
2103
|
-
async function fetchIntegrationFiles(integrationId, baseUrl = GITHUB_RAW_BASE) {
|
|
2104
|
-
if (isLocalPath(baseUrl)) return readDirRecursive((0, node_path.join)(baseUrl, integrationId, "assets"));
|
|
2105
|
-
return fetchWithCache(`integration_files_${integrationId}_${baseUrl.replace(/[^a-zA-Z0-9]/g, "_")}`, async () => {
|
|
2106
|
-
const filesUrl = `${baseUrl}/${integrationId}/files.json`;
|
|
2107
|
-
const response = await fetch(filesUrl);
|
|
2108
|
-
if (!response.ok) return {};
|
|
2109
|
-
const fileList = await response.json();
|
|
2110
|
-
const files = {};
|
|
2111
|
-
await Promise.all(fileList.map(async (filePath) => {
|
|
2112
|
-
const fileUrl = `${baseUrl}/${integrationId}/assets/${filePath}`;
|
|
2113
|
-
const fileResponse = await fetch(fileUrl);
|
|
2114
|
-
if (fileResponse.ok) files[filePath] = await fileResponse.text();
|
|
2115
|
-
}));
|
|
2116
|
-
return files;
|
|
2117
|
-
}, CACHE_TTL_MS);
|
|
2118
|
-
}
|
|
2119
|
-
/**
|
|
2120
|
-
* Fetch integration package.json if it exists
|
|
2121
|
-
*/
|
|
2122
|
-
async function fetchIntegrationPackageJson(integrationId, baseUrl) {
|
|
2123
|
-
if (isLocalPath(baseUrl)) {
|
|
2124
|
-
const pkgPath = (0, node_path.join)(baseUrl, integrationId, "package.json");
|
|
2125
|
-
if ((0, node_fs.existsSync)(pkgPath)) return JSON.parse((0, node_fs.readFileSync)(pkgPath, "utf-8"));
|
|
2126
|
-
return null;
|
|
2127
|
-
}
|
|
2128
|
-
const url = `${baseUrl}/${integrationId}/package.json`;
|
|
2129
|
-
const response = await fetch(url);
|
|
2130
|
-
if (!response.ok) return null;
|
|
2131
|
-
return response.json();
|
|
2132
|
-
}
|
|
2133
|
-
/**
|
|
2134
|
-
* Fetch a complete compiled integration from GitHub
|
|
2135
|
-
*/
|
|
2136
|
-
async function fetchIntegration(integrationId, baseUrl = GITHUB_RAW_BASE) {
|
|
2137
|
-
const [info, files, pkgJson] = await Promise.all([
|
|
2138
|
-
fetchIntegrationInfo(integrationId, baseUrl),
|
|
2139
|
-
fetchIntegrationFiles(integrationId, baseUrl),
|
|
2140
|
-
fetchIntegrationPackageJson(integrationId, baseUrl)
|
|
2141
|
-
]);
|
|
2142
|
-
const packageAdditions = info.packageAdditions ?? {};
|
|
2143
|
-
if (pkgJson) {
|
|
2144
|
-
if (pkgJson.dependencies) packageAdditions.dependencies = {
|
|
2145
|
-
...packageAdditions.dependencies,
|
|
2146
|
-
...pkgJson.dependencies
|
|
2147
|
-
};
|
|
2148
|
-
if (pkgJson.devDependencies) packageAdditions.devDependencies = {
|
|
2149
|
-
...packageAdditions.devDependencies,
|
|
2150
|
-
...pkgJson.devDependencies
|
|
2151
|
-
};
|
|
2152
|
-
if (pkgJson.scripts) packageAdditions.scripts = {
|
|
2153
|
-
...packageAdditions.scripts,
|
|
2154
|
-
...pkgJson.scripts
|
|
2155
|
-
};
|
|
2156
|
-
}
|
|
2157
|
-
return IntegrationCompiledSchema.parse({
|
|
2158
|
-
...info,
|
|
2159
|
-
id: integrationId,
|
|
2160
|
-
files,
|
|
2161
|
-
packageAdditions: Object.keys(packageAdditions).length > 0 ? packageAdditions : void 0,
|
|
2162
|
-
deletedFiles: []
|
|
2163
|
-
});
|
|
2164
|
-
}
|
|
2165
|
-
/**
|
|
2166
|
-
* Fetch multiple integrations in parallel
|
|
2167
|
-
*/
|
|
2168
|
-
async function fetchIntegrations(integrationIds, baseUrl = GITHUB_RAW_BASE) {
|
|
2169
|
-
return Promise.all(integrationIds.map((id) => fetchIntegration(id, baseUrl)));
|
|
2170
|
-
}
|
|
2171
|
-
|
|
2172
1829
|
//#endregion
|
|
2173
1830
|
//#region src/engine/custom-addons/shared.ts
|
|
2174
1831
|
/**
|
|
@@ -2265,7 +1922,7 @@ function createPackageAdditions(originalPackageJson, currentPackageJson) {
|
|
|
2265
1922
|
}
|
|
2266
1923
|
async function createCompileOptionsFromPersisted(persisted, integrationsPath) {
|
|
2267
1924
|
let chosenIntegrations = [];
|
|
2268
|
-
if (persisted.chosenIntegrations.length > 0) chosenIntegrations = await fetchIntegrations(persisted.chosenIntegrations, integrationsPath);
|
|
1925
|
+
if (persisted.chosenIntegrations.length > 0) chosenIntegrations = await require_fetch.fetchIntegrations(persisted.chosenIntegrations, integrationsPath);
|
|
2269
1926
|
return {
|
|
2270
1927
|
projectName: persisted.projectName,
|
|
2271
1928
|
framework: persisted.framework,
|
|
@@ -2486,7 +2143,7 @@ async function loadRemoteIntegration(url) {
|
|
|
2486
2143
|
const response = await fetch(url);
|
|
2487
2144
|
if (!response.ok) throw new Error(`Failed to fetch integration from ${url}: ${response.statusText}`);
|
|
2488
2145
|
const jsonContent = await response.json();
|
|
2489
|
-
const result = IntegrationCompiledSchema.safeParse(jsonContent);
|
|
2146
|
+
const result = require_fetch.IntegrationCompiledSchema.safeParse(jsonContent);
|
|
2490
2147
|
if (!result.success) throw new Error(`Invalid integration at ${url}: ${result.error.message}`);
|
|
2491
2148
|
const integration = result.data;
|
|
2492
2149
|
if (!integration.id) integration.id = url;
|
|
@@ -2563,7 +2220,7 @@ async function loadTemplate(url) {
|
|
|
2563
2220
|
const response = await fetch(url);
|
|
2564
2221
|
if (!response.ok) throw new Error(`Failed to fetch template from ${url}: ${response.statusText}`);
|
|
2565
2222
|
const jsonContent = await response.json();
|
|
2566
|
-
const result = CustomTemplateCompiledSchema.safeParse(jsonContent);
|
|
2223
|
+
const result = require_fetch.CustomTemplateCompiledSchema.safeParse(jsonContent);
|
|
2567
2224
|
if (!result.success) throw new Error(`Invalid template at ${url}: ${result.error.message}`);
|
|
2568
2225
|
const template = result.data;
|
|
2569
2226
|
if (!template.id) template.id = url;
|
|
@@ -2577,102 +2234,6 @@ Object.defineProperty(exports, 'CONFIG_FILE', {
|
|
|
2577
2234
|
return CONFIG_FILE;
|
|
2578
2235
|
}
|
|
2579
2236
|
});
|
|
2580
|
-
Object.defineProperty(exports, 'CategorySchema', {
|
|
2581
|
-
enumerable: true,
|
|
2582
|
-
get: function () {
|
|
2583
|
-
return CategorySchema;
|
|
2584
|
-
}
|
|
2585
|
-
});
|
|
2586
|
-
Object.defineProperty(exports, 'CommandSchema', {
|
|
2587
|
-
enumerable: true,
|
|
2588
|
-
get: function () {
|
|
2589
|
-
return CommandSchema;
|
|
2590
|
-
}
|
|
2591
|
-
});
|
|
2592
|
-
Object.defineProperty(exports, 'CustomTemplateCompiledSchema', {
|
|
2593
|
-
enumerable: true,
|
|
2594
|
-
get: function () {
|
|
2595
|
-
return CustomTemplateCompiledSchema;
|
|
2596
|
-
}
|
|
2597
|
-
});
|
|
2598
|
-
Object.defineProperty(exports, 'CustomTemplateInfoSchema', {
|
|
2599
|
-
enumerable: true,
|
|
2600
|
-
get: function () {
|
|
2601
|
-
return CustomTemplateInfoSchema;
|
|
2602
|
-
}
|
|
2603
|
-
});
|
|
2604
|
-
Object.defineProperty(exports, 'EnvVarSchema', {
|
|
2605
|
-
enumerable: true,
|
|
2606
|
-
get: function () {
|
|
2607
|
-
return EnvVarSchema;
|
|
2608
|
-
}
|
|
2609
|
-
});
|
|
2610
|
-
Object.defineProperty(exports, 'HookSchema', {
|
|
2611
|
-
enumerable: true,
|
|
2612
|
-
get: function () {
|
|
2613
|
-
return HookSchema;
|
|
2614
|
-
}
|
|
2615
|
-
});
|
|
2616
|
-
Object.defineProperty(exports, 'IntegrationCompiledSchema', {
|
|
2617
|
-
enumerable: true,
|
|
2618
|
-
get: function () {
|
|
2619
|
-
return IntegrationCompiledSchema;
|
|
2620
|
-
}
|
|
2621
|
-
});
|
|
2622
|
-
Object.defineProperty(exports, 'IntegrationInfoSchema', {
|
|
2623
|
-
enumerable: true,
|
|
2624
|
-
get: function () {
|
|
2625
|
-
return IntegrationInfoSchema;
|
|
2626
|
-
}
|
|
2627
|
-
});
|
|
2628
|
-
Object.defineProperty(exports, 'IntegrationOptionSchema', {
|
|
2629
|
-
enumerable: true,
|
|
2630
|
-
get: function () {
|
|
2631
|
-
return IntegrationOptionSchema;
|
|
2632
|
-
}
|
|
2633
|
-
});
|
|
2634
|
-
Object.defineProperty(exports, 'IntegrationOptionsSchema', {
|
|
2635
|
-
enumerable: true,
|
|
2636
|
-
get: function () {
|
|
2637
|
-
return IntegrationOptionsSchema;
|
|
2638
|
-
}
|
|
2639
|
-
});
|
|
2640
|
-
Object.defineProperty(exports, 'IntegrationPhaseSchema', {
|
|
2641
|
-
enumerable: true,
|
|
2642
|
-
get: function () {
|
|
2643
|
-
return IntegrationPhaseSchema;
|
|
2644
|
-
}
|
|
2645
|
-
});
|
|
2646
|
-
Object.defineProperty(exports, 'IntegrationTypeSchema', {
|
|
2647
|
-
enumerable: true,
|
|
2648
|
-
get: function () {
|
|
2649
|
-
return IntegrationTypeSchema;
|
|
2650
|
-
}
|
|
2651
|
-
});
|
|
2652
|
-
Object.defineProperty(exports, 'ManifestIntegrationSchema', {
|
|
2653
|
-
enumerable: true,
|
|
2654
|
-
get: function () {
|
|
2655
|
-
return ManifestIntegrationSchema;
|
|
2656
|
-
}
|
|
2657
|
-
});
|
|
2658
|
-
Object.defineProperty(exports, 'ManifestSchema', {
|
|
2659
|
-
enumerable: true,
|
|
2660
|
-
get: function () {
|
|
2661
|
-
return ManifestSchema;
|
|
2662
|
-
}
|
|
2663
|
-
});
|
|
2664
|
-
Object.defineProperty(exports, 'RouteSchema', {
|
|
2665
|
-
enumerable: true,
|
|
2666
|
-
get: function () {
|
|
2667
|
-
return RouteSchema;
|
|
2668
|
-
}
|
|
2669
|
-
});
|
|
2670
|
-
Object.defineProperty(exports, 'RouterModeSchema', {
|
|
2671
|
-
enumerable: true,
|
|
2672
|
-
get: function () {
|
|
2673
|
-
return RouterModeSchema;
|
|
2674
|
-
}
|
|
2675
|
-
});
|
|
2676
2237
|
Object.defineProperty(exports, '__toESM', {
|
|
2677
2238
|
enumerable: true,
|
|
2678
2239
|
get: function () {
|
|
@@ -2703,36 +2264,6 @@ Object.defineProperty(exports, 'compileWithAttribution', {
|
|
|
2703
2264
|
return compileWithAttribution;
|
|
2704
2265
|
}
|
|
2705
2266
|
});
|
|
2706
|
-
Object.defineProperty(exports, 'fetchIntegration', {
|
|
2707
|
-
enumerable: true,
|
|
2708
|
-
get: function () {
|
|
2709
|
-
return fetchIntegration;
|
|
2710
|
-
}
|
|
2711
|
-
});
|
|
2712
|
-
Object.defineProperty(exports, 'fetchIntegrationFiles', {
|
|
2713
|
-
enumerable: true,
|
|
2714
|
-
get: function () {
|
|
2715
|
-
return fetchIntegrationFiles;
|
|
2716
|
-
}
|
|
2717
|
-
});
|
|
2718
|
-
Object.defineProperty(exports, 'fetchIntegrationInfo', {
|
|
2719
|
-
enumerable: true,
|
|
2720
|
-
get: function () {
|
|
2721
|
-
return fetchIntegrationInfo;
|
|
2722
|
-
}
|
|
2723
|
-
});
|
|
2724
|
-
Object.defineProperty(exports, 'fetchIntegrations', {
|
|
2725
|
-
enumerable: true,
|
|
2726
|
-
get: function () {
|
|
2727
|
-
return fetchIntegrations;
|
|
2728
|
-
}
|
|
2729
|
-
});
|
|
2730
|
-
Object.defineProperty(exports, 'fetchManifest', {
|
|
2731
|
-
enumerable: true,
|
|
2732
|
-
get: function () {
|
|
2733
|
-
return fetchManifest;
|
|
2734
|
-
}
|
|
2735
|
-
});
|
|
2736
2267
|
Object.defineProperty(exports, 'initIntegration', {
|
|
2737
2268
|
enumerable: true,
|
|
2738
2269
|
get: function () {
|