@lukoweb/apitogo 0.2.51 → 0.2.52
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/cli.js +95 -55
- package/package.json +1 -1
- package/src/config/v2/wrapper.ts +14 -2
- package/src/vite/api/SchemaManager.ts +376 -371
- package/src/vite/plugin-api.ts +328 -328
- package/src/vite/plugin-config.ts +192 -131
package/dist/cli/cli.js
CHANGED
|
@@ -7966,6 +7966,12 @@ function contentGlob(configDir, glob9) {
|
|
|
7966
7966
|
const relative = path13.relative(configDir, absolute).split(path13.sep).join("/");
|
|
7967
7967
|
return `${negated ? "!" : ""}/${CONTENT_LINK}/${relative}`;
|
|
7968
7968
|
}
|
|
7969
|
+
function contentFile(configDir, file) {
|
|
7970
|
+
const relative = path13.relative(configDir, file);
|
|
7971
|
+
if (relative.startsWith("..") || path13.isAbsolute(relative))
|
|
7972
|
+
return file.split(path13.sep).join("/");
|
|
7973
|
+
return `${CONTENT_LINK}/${relative.split(path13.sep).join("/")}`;
|
|
7974
|
+
}
|
|
7969
7975
|
var PLANS_CONSOLE_CAPABILITIES = [
|
|
7970
7976
|
"catalog",
|
|
7971
7977
|
"checkout",
|
|
@@ -8128,13 +8134,13 @@ function buildSiteConfig(resolved, plan2, theme, extras = {}) {
|
|
|
8128
8134
|
},
|
|
8129
8135
|
modules: {
|
|
8130
8136
|
docs: { enabled: plan2.docs },
|
|
8131
|
-
// A custom home page (`portal.landing`) is served at `/`; the build imports the component
|
|
8137
|
+
// A custom home page (`portal.landing`) is served at `/`; the build imports the component through the content link.
|
|
8132
8138
|
...portal?.landing ? {
|
|
8133
8139
|
landing: {
|
|
8134
8140
|
enabled: true,
|
|
8135
8141
|
path: "/",
|
|
8136
8142
|
layout: "landing",
|
|
8137
|
-
page: portal.landing
|
|
8143
|
+
page: contentFile(resolved.configDir, portal.landing)
|
|
8138
8144
|
}
|
|
8139
8145
|
} : {},
|
|
8140
8146
|
// The plans pages (pricing, choosing a plan) exist only when billing is on, and the plans service is what makes it so.
|
|
@@ -9704,7 +9710,7 @@ init_invariant();
|
|
|
9704
9710
|
|
|
9705
9711
|
// src/cli/check/v2.ts
|
|
9706
9712
|
init_apitogo_config_core();
|
|
9707
|
-
import { readFile as
|
|
9713
|
+
import { readFile as readFile18 } from "node:fs/promises";
|
|
9708
9714
|
import path50 from "node:path";
|
|
9709
9715
|
|
|
9710
9716
|
// src/cli/platform/client/platform-api.ts
|
|
@@ -10527,8 +10533,8 @@ var PlatformApiClient = class {
|
|
|
10527
10533
|
}
|
|
10528
10534
|
};
|
|
10529
10535
|
async function readFileBytes(filePath) {
|
|
10530
|
-
const { readFile:
|
|
10531
|
-
const buffer = await
|
|
10536
|
+
const { readFile: readFile29 } = await import("node:fs/promises");
|
|
10537
|
+
const buffer = await readFile29(filePath);
|
|
10532
10538
|
const arrayBuffer = new ArrayBuffer(buffer.byteLength);
|
|
10533
10539
|
new Uint8Array(arrayBuffer).set(buffer);
|
|
10534
10540
|
return arrayBuffer;
|
|
@@ -10625,7 +10631,7 @@ function resolveProjectId(explicit, config2) {
|
|
|
10625
10631
|
import {
|
|
10626
10632
|
access as access4,
|
|
10627
10633
|
mkdir as mkdir12,
|
|
10628
|
-
readFile as
|
|
10634
|
+
readFile as readFile15,
|
|
10629
10635
|
rename as rename6,
|
|
10630
10636
|
rm as rm8,
|
|
10631
10637
|
writeFile as writeFile15
|
|
@@ -10633,7 +10639,7 @@ import {
|
|
|
10633
10639
|
import path49 from "node:path";
|
|
10634
10640
|
|
|
10635
10641
|
// src/vite/build.ts
|
|
10636
|
-
import { mkdir as mkdir11, readFile as
|
|
10642
|
+
import { mkdir as mkdir11, readFile as readFile13, rename as rename5, rm as rm7, writeFile as writeFile13 } from "node:fs/promises";
|
|
10637
10643
|
import path47 from "node:path";
|
|
10638
10644
|
import { build as esbuild } from "esbuild";
|
|
10639
10645
|
import { build as viteBuild, mergeConfig as mergeConfig3 } from "vite";
|
|
@@ -10781,7 +10787,7 @@ import {
|
|
|
10781
10787
|
// package.json
|
|
10782
10788
|
var package_default = {
|
|
10783
10789
|
name: "@lukoweb/apitogo",
|
|
10784
|
-
version: "0.2.
|
|
10790
|
+
version: "0.2.52",
|
|
10785
10791
|
type: "module",
|
|
10786
10792
|
sideEffects: [
|
|
10787
10793
|
"**/*.css",
|
|
@@ -12712,7 +12718,7 @@ var SchemaManager = class {
|
|
|
12712
12718
|
this.storeDir,
|
|
12713
12719
|
`${prefixPath}-${path26.basename(filePath)}${paramsSuffix(params)}.js`
|
|
12714
12720
|
);
|
|
12715
|
-
const importKey = processedFilePath;
|
|
12721
|
+
const importKey = path26.posix.basename(processedFilePath);
|
|
12716
12722
|
await fs3.writeFile(processedFilePath, code);
|
|
12717
12723
|
const processedJsonPath = paramsSuffix(params) ? processedFilePath.replace(/\.js$/, ".json") : "";
|
|
12718
12724
|
if (processedJsonPath) {
|
|
@@ -12739,6 +12745,7 @@ var SchemaManager = class {
|
|
|
12739
12745
|
inputPath: filePath,
|
|
12740
12746
|
params,
|
|
12741
12747
|
importKey,
|
|
12748
|
+
processedFilePath,
|
|
12742
12749
|
downloadUrl: this.createSchemaPath(
|
|
12743
12750
|
filePath,
|
|
12744
12751
|
versionPath,
|
|
@@ -12791,6 +12798,7 @@ var SchemaManager = class {
|
|
|
12791
12798
|
inputPath: path26.resolve(this.config.__meta.rootDir, input5.input),
|
|
12792
12799
|
params: input5.params,
|
|
12793
12800
|
importKey: "",
|
|
12801
|
+
processedFilePath: "",
|
|
12794
12802
|
downloadUrl: "",
|
|
12795
12803
|
processedJsonPath: "",
|
|
12796
12804
|
processedTime: 0
|
|
@@ -13306,7 +13314,7 @@ var viteApiPlugin = async () => {
|
|
|
13306
13314
|
` },`,
|
|
13307
13315
|
` schemaImports: {`,
|
|
13308
13316
|
...schemaImports.map(
|
|
13309
|
-
(s) => `
|
|
13317
|
+
(s) => ` ${JSON.stringify(s.importKey)}: () => import("${s.processedFilePath.replaceAll("\\", "/")}?d=${s.processedTime}"),`
|
|
13310
13318
|
),
|
|
13311
13319
|
` },`,
|
|
13312
13320
|
"}));"
|
|
@@ -13468,6 +13476,7 @@ var plugin_component_default = viteAliasPlugin;
|
|
|
13468
13476
|
// src/vite/plugin-config.ts
|
|
13469
13477
|
init_package_json();
|
|
13470
13478
|
init_loader();
|
|
13479
|
+
import { readFile as readFile11 } from "node:fs/promises";
|
|
13471
13480
|
import path32 from "node:path";
|
|
13472
13481
|
import { normalizePath } from "vite";
|
|
13473
13482
|
var virtualModuleId3 = "virtual:zudoku-config";
|
|
@@ -13476,18 +13485,54 @@ var browserConfigLoaderPath = path32.join(
|
|
|
13476
13485
|
getZudokuRootDir(),
|
|
13477
13486
|
"src/config/apitogo-config-loader.browser.ts"
|
|
13478
13487
|
);
|
|
13488
|
+
var BUILD_ONLY_KEYS = /* @__PURE__ */ new Set(["page"]);
|
|
13489
|
+
function stripBuildOnlyPaths(value) {
|
|
13490
|
+
if (Array.isArray(value)) return value.map(stripBuildOnlyPaths);
|
|
13491
|
+
if (typeof value !== "object" || value === null) return value;
|
|
13492
|
+
return Object.fromEntries(
|
|
13493
|
+
Object.entries(value).flatMap(
|
|
13494
|
+
([key, child]) => BUILD_ONLY_KEYS.has(key) && typeof child === "string" ? [] : [[key, stripBuildOnlyPaths(child)]]
|
|
13495
|
+
)
|
|
13496
|
+
);
|
|
13497
|
+
}
|
|
13479
13498
|
function serializeClientConfig(config2) {
|
|
13480
13499
|
const {
|
|
13481
13500
|
plugins: _plugins,
|
|
13482
13501
|
__meta: _meta,
|
|
13502
|
+
// Folders of the plugin packages on the build machine, for the build's Tailwind sources only.
|
|
13503
|
+
__pluginDirs: _pluginDirs,
|
|
13483
13504
|
__resolvedModules,
|
|
13505
|
+
modules,
|
|
13484
13506
|
...rest
|
|
13485
13507
|
} = config2;
|
|
13486
13508
|
return JSON.stringify(
|
|
13487
|
-
{
|
|
13509
|
+
{
|
|
13510
|
+
...rest,
|
|
13511
|
+
...modules !== void 0 ? { modules: stripBuildOnlyPaths(modules) } : {},
|
|
13512
|
+
__resolvedModules
|
|
13513
|
+
},
|
|
13488
13514
|
(_key, value) => typeof value === "function" ? void 0 : value
|
|
13489
13515
|
);
|
|
13490
13516
|
}
|
|
13517
|
+
function clientMetaOf(meta) {
|
|
13518
|
+
return {
|
|
13519
|
+
pricingEnabled: meta.pricingEnabled,
|
|
13520
|
+
authenticationEnabled: meta.authenticationEnabled,
|
|
13521
|
+
previewPlans: meta.previewPlans,
|
|
13522
|
+
gatewayBaseUrl: meta.gatewayBaseUrl
|
|
13523
|
+
};
|
|
13524
|
+
}
|
|
13525
|
+
async function rawConfigSource(configPath) {
|
|
13526
|
+
if (!configPath.toLowerCase().endsWith(".json"))
|
|
13527
|
+
return `import rawConfig from "${normalizePath(configPath)}";`;
|
|
13528
|
+
let navigation;
|
|
13529
|
+
try {
|
|
13530
|
+
navigation = JSON.parse(await readFile11(configPath, "utf8")).navigation;
|
|
13531
|
+
} catch {
|
|
13532
|
+
navigation = void 0;
|
|
13533
|
+
}
|
|
13534
|
+
return `const rawConfig = ${JSON.stringify(navigation === void 0 ? {} : { navigation })};`;
|
|
13535
|
+
}
|
|
13491
13536
|
var viteConfigPlugin = () => {
|
|
13492
13537
|
let viteConfig;
|
|
13493
13538
|
return {
|
|
@@ -13520,15 +13565,10 @@ var viteConfigPlugin = () => {
|
|
|
13520
13565
|
},
|
|
13521
13566
|
viteConfig.root
|
|
13522
13567
|
);
|
|
13523
|
-
const clientMeta =
|
|
13524
|
-
|
|
13525
|
-
pricingEnabled: loadedConfig.__meta.pricingEnabled,
|
|
13526
|
-
authenticationEnabled: loadedConfig.__meta.authenticationEnabled,
|
|
13527
|
-
previewPlans: loadedConfig.__meta.previewPlans,
|
|
13528
|
-
gatewayBaseUrl: loadedConfig.__meta.gatewayBaseUrl
|
|
13529
|
-
};
|
|
13568
|
+
const clientMeta = clientMetaOf(loadedConfig.__meta);
|
|
13569
|
+
this.addWatchFile(configPath);
|
|
13530
13570
|
return `
|
|
13531
|
-
|
|
13571
|
+
${await rawConfigSource(configPath)}
|
|
13532
13572
|
import { runPluginTransformConfig } from "@lukoweb/apitogo/plugins";
|
|
13533
13573
|
|
|
13534
13574
|
const embeddedConfig = ${serializeClientConfig(loadedConfig)};
|
|
@@ -15177,7 +15217,7 @@ async function writeOutput(dir, {
|
|
|
15177
15217
|
// src/vite/prerender/prerender.ts
|
|
15178
15218
|
init_logger();
|
|
15179
15219
|
init_file_exists();
|
|
15180
|
-
import { readFile as
|
|
15220
|
+
import { readFile as readFile12, rm as rm6 } from "node:fs/promises";
|
|
15181
15221
|
import os from "node:os";
|
|
15182
15222
|
import path46 from "node:path";
|
|
15183
15223
|
import { pathToFileURL } from "node:url";
|
|
@@ -15453,7 +15493,7 @@ var prerender = async ({
|
|
|
15453
15493
|
);
|
|
15454
15494
|
let markdownFileInfos = [];
|
|
15455
15495
|
if (await fileExists(markdownInfoPath)) {
|
|
15456
|
-
const markdownInfoContent = await
|
|
15496
|
+
const markdownInfoContent = await readFile12(markdownInfoPath, "utf-8");
|
|
15457
15497
|
markdownFileInfos = JSON.parse(markdownInfoContent);
|
|
15458
15498
|
}
|
|
15459
15499
|
if (llmsConfig.llmsTxt || llmsConfig.llmsTxtFull) {
|
|
@@ -15604,7 +15644,7 @@ var bundleSSREntry = async (options) => {
|
|
|
15604
15644
|
const { dir, adapter, serverOutDir, serverConfigFilename, html, basePath } = options;
|
|
15605
15645
|
const tempEntryPath = path47.join(dir, "__ssr-entry.ts");
|
|
15606
15646
|
const packageRoot = getZudokuRootDir();
|
|
15607
|
-
const templateContent = await
|
|
15647
|
+
const templateContent = await readFile13(
|
|
15608
15648
|
path47.join(packageRoot, "src/vite/ssr-templates", `${adapter}.ts`),
|
|
15609
15649
|
"utf-8"
|
|
15610
15650
|
);
|
|
@@ -15635,7 +15675,7 @@ init_package_json();
|
|
|
15635
15675
|
|
|
15636
15676
|
// src/cli/init/v2-packages.ts
|
|
15637
15677
|
import { existsSync as existsSync5 } from "node:fs";
|
|
15638
|
-
import { readFile as
|
|
15678
|
+
import { readFile as readFile14, writeFile as writeFile14 } from "node:fs/promises";
|
|
15639
15679
|
import path48 from "node:path";
|
|
15640
15680
|
var CORE_PACKAGES = [
|
|
15641
15681
|
"@lukoweb/apitogo",
|
|
@@ -15782,7 +15822,7 @@ async function buildV2(options) {
|
|
|
15782
15822
|
}
|
|
15783
15823
|
|
|
15784
15824
|
// src/cli/check/gateway-online.ts
|
|
15785
|
-
import { readFile as
|
|
15825
|
+
import { readFile as readFile16 } from "node:fs/promises";
|
|
15786
15826
|
var SPEC_SEND_LIMIT = 5 * 1024 * 1024 + 64 * 1024;
|
|
15787
15827
|
var issue2 = (code, path97, message, hint) => ({ code, path: path97, message, hint });
|
|
15788
15828
|
function capabilityIssues(gateway, answer) {
|
|
@@ -15846,7 +15886,7 @@ async function onlineGatewayRules(gateway, projectId, api, derivedCors = []) {
|
|
|
15846
15886
|
const specFile = gateway.specs[0];
|
|
15847
15887
|
if (specFile) {
|
|
15848
15888
|
try {
|
|
15849
|
-
const text = await
|
|
15889
|
+
const text = await readFile16(specFile, "utf8");
|
|
15850
15890
|
if (text.length <= SPEC_SEND_LIMIT) spec = text;
|
|
15851
15891
|
} catch {
|
|
15852
15892
|
}
|
|
@@ -15873,7 +15913,7 @@ async function onlineGatewayRules(gateway, projectId, api, derivedCors = []) {
|
|
|
15873
15913
|
}
|
|
15874
15914
|
|
|
15875
15915
|
// src/cli/deploy/plans-file.ts
|
|
15876
|
-
import { readFile as
|
|
15916
|
+
import { readFile as readFile17 } from "node:fs/promises";
|
|
15877
15917
|
import { z as z14 } from "zod";
|
|
15878
15918
|
init_invariant();
|
|
15879
15919
|
var PlansFileError = class extends ApitogoError {
|
|
@@ -15918,7 +15958,7 @@ var issuesOf = (error) => error.issues.map(
|
|
|
15918
15958
|
async function readPlansFile(file) {
|
|
15919
15959
|
let text;
|
|
15920
15960
|
try {
|
|
15921
|
-
text = await
|
|
15961
|
+
text = await readFile17(file, "utf8");
|
|
15922
15962
|
} catch {
|
|
15923
15963
|
throw new PlansFileError(
|
|
15924
15964
|
"PLANS_FILE_UNREADABLE",
|
|
@@ -16110,7 +16150,7 @@ var withPlanName = (message, sku) => !sku || message.toLowerCase().startsWith(`p
|
|
|
16110
16150
|
async function isConfigV2(dir) {
|
|
16111
16151
|
try {
|
|
16112
16152
|
return /"version"\s*:\s*2\b/.test(
|
|
16113
|
-
await
|
|
16153
|
+
await readFile18(path50.join(dir, APITOGO_CONFIG_FILENAME), "utf8")
|
|
16114
16154
|
);
|
|
16115
16155
|
} catch {
|
|
16116
16156
|
return false;
|
|
@@ -17191,7 +17231,7 @@ function formatDevPortalBackendResponse(projectId, backend) {
|
|
|
17191
17231
|
// src/cli/platform/helpers/dev-portal-manifest.ts
|
|
17192
17232
|
init_gateway_limits();
|
|
17193
17233
|
import { existsSync as existsSync7 } from "node:fs";
|
|
17194
|
-
import { access as access5, mkdir as mkdir13, readFile as
|
|
17234
|
+
import { access as access5, mkdir as mkdir13, readFile as readFile19, writeFile as writeFile16 } from "node:fs/promises";
|
|
17195
17235
|
import path56 from "node:path";
|
|
17196
17236
|
|
|
17197
17237
|
// src/cli/make-config/header-pricing-nav.ts
|
|
@@ -17771,7 +17811,7 @@ function mergePublishPrerequisitesWithPlatformValidation(prerequisites, manifest
|
|
|
17771
17811
|
async function readManifest2(siteDirectory) {
|
|
17772
17812
|
const filePath = manifestFilePath(siteDirectory);
|
|
17773
17813
|
if (await pathExists(filePath)) {
|
|
17774
|
-
const raw = await
|
|
17814
|
+
const raw = await readFile19(filePath, "utf8");
|
|
17775
17815
|
const config2 = JSON.parse(raw);
|
|
17776
17816
|
return extractManifestFromConfig(config2);
|
|
17777
17817
|
}
|
|
@@ -17782,7 +17822,7 @@ async function writeManifest2(siteDirectory, manifest) {
|
|
|
17782
17822
|
await mkdir13(path56.dirname(filePath), { recursive: true });
|
|
17783
17823
|
let config2 = {};
|
|
17784
17824
|
if (await pathExists(filePath)) {
|
|
17785
|
-
const raw = await
|
|
17825
|
+
const raw = await readFile19(filePath, "utf8");
|
|
17786
17826
|
config2 = JSON.parse(raw);
|
|
17787
17827
|
}
|
|
17788
17828
|
const {
|
|
@@ -17801,7 +17841,7 @@ import {
|
|
|
17801
17841
|
access as access6,
|
|
17802
17842
|
appendFile,
|
|
17803
17843
|
mkdir as mkdir14,
|
|
17804
|
-
readFile as
|
|
17844
|
+
readFile as readFile20,
|
|
17805
17845
|
unlink,
|
|
17806
17846
|
writeFile as writeFile17
|
|
17807
17847
|
} from "node:fs/promises";
|
|
@@ -17907,7 +17947,7 @@ function applyEnvOverrides2(config2, env) {
|
|
|
17907
17947
|
}
|
|
17908
17948
|
async function readEnvFile(filePath) {
|
|
17909
17949
|
try {
|
|
17910
|
-
const raw = await
|
|
17950
|
+
const raw = await readFile20(filePath, "utf8");
|
|
17911
17951
|
const env = {};
|
|
17912
17952
|
for (const line2 of raw.split("\n")) {
|
|
17913
17953
|
const trimmed = line2.trim();
|
|
@@ -18040,7 +18080,7 @@ var SECRETS_COLLECTION_INSTRUCTION = "For go-live, plans must already be in apit
|
|
|
18040
18080
|
|
|
18041
18081
|
// src/cli/platform/helpers/dev-portal-site-validation.ts
|
|
18042
18082
|
init_gateway_limits();
|
|
18043
|
-
import { readFile as
|
|
18083
|
+
import { readFile as readFile21 } from "node:fs/promises";
|
|
18044
18084
|
import { createRequire as createRequire2 } from "node:module";
|
|
18045
18085
|
import path58 from "node:path";
|
|
18046
18086
|
var cachedFallbackTs;
|
|
@@ -18218,7 +18258,7 @@ async function validateDevPortalSiteConfig(sourceDirectory, options) {
|
|
|
18218
18258
|
let parsed;
|
|
18219
18259
|
let parseFailed = false;
|
|
18220
18260
|
try {
|
|
18221
|
-
parsed = JSON.parse(await
|
|
18261
|
+
parsed = JSON.parse(await readFile21(jsonPath, "utf8"));
|
|
18222
18262
|
} catch (error) {
|
|
18223
18263
|
parseFailed = true;
|
|
18224
18264
|
issues.push({
|
|
@@ -18257,7 +18297,7 @@ async function validateDevPortalSiteConfig(sourceDirectory, options) {
|
|
|
18257
18297
|
} else {
|
|
18258
18298
|
for (const relativeFile of existingTsxFiles) {
|
|
18259
18299
|
checkedFiles.push(relativeFile);
|
|
18260
|
-
const content = await
|
|
18300
|
+
const content = await readFile21(
|
|
18261
18301
|
path58.join(resolvedDir, relativeFile),
|
|
18262
18302
|
"utf8"
|
|
18263
18303
|
);
|
|
@@ -18280,7 +18320,7 @@ async function validateDevPortalSiteConfig(sourceDirectory, options) {
|
|
|
18280
18320
|
|
|
18281
18321
|
// src/cli/platform/helpers/npm-build.ts
|
|
18282
18322
|
import { spawn as spawn2 } from "node:child_process";
|
|
18283
|
-
import { access as access7, readFile as
|
|
18323
|
+
import { access as access7, readFile as readFile22 } from "node:fs/promises";
|
|
18284
18324
|
import path59 from "node:path";
|
|
18285
18325
|
var BUILD_LOG_TAIL_BYTES = 8192;
|
|
18286
18326
|
var MIN_NODE_MAJOR = 20;
|
|
@@ -18926,7 +18966,7 @@ import { createInterface as createInterface3 } from "node:readline/promises";
|
|
|
18926
18966
|
|
|
18927
18967
|
// src/cli/make-config/v2-edits.ts
|
|
18928
18968
|
init_apitogo_config_core();
|
|
18929
|
-
import { access as access8, mkdir as mkdir15, readFile as
|
|
18969
|
+
import { access as access8, mkdir as mkdir15, readFile as readFile23, writeFile as writeFile18 } from "node:fs/promises";
|
|
18930
18970
|
import path62 from "node:path";
|
|
18931
18971
|
import { glob as glob8 } from "glob";
|
|
18932
18972
|
init_invariant();
|
|
@@ -19158,7 +19198,7 @@ async function writeDocsPage(project, input5) {
|
|
|
19158
19198
|
"Leave out --page-update to add it."
|
|
19159
19199
|
);
|
|
19160
19200
|
}
|
|
19161
|
-
const source = await
|
|
19201
|
+
const source = await readFile23(existing, "utf8");
|
|
19162
19202
|
const title = input5.title?.trim() || (existing.endsWith(".tsx") ? tsxPageLabel(source, existing) : titleOf(source));
|
|
19163
19203
|
file = existing;
|
|
19164
19204
|
action = "updated";
|
|
@@ -19247,7 +19287,7 @@ async function upsertPlan(project, plan2) {
|
|
|
19247
19287
|
if (await exists4(plans.file)) {
|
|
19248
19288
|
let raw;
|
|
19249
19289
|
try {
|
|
19250
|
-
raw = JSON.parse(await
|
|
19290
|
+
raw = JSON.parse(await readFile23(plans.file, "utf8"));
|
|
19251
19291
|
} catch (error) {
|
|
19252
19292
|
throw new ConfigEditError(
|
|
19253
19293
|
`${relativeToConfig(project, plans.file)} is not valid JSON (${error.message}).`
|
|
@@ -19723,7 +19763,7 @@ var config_default = {
|
|
|
19723
19763
|
// src/cli/create/handler.ts
|
|
19724
19764
|
init_apitogo_config_core();
|
|
19725
19765
|
import { execFile } from "node:child_process";
|
|
19726
|
-
import { readFile as
|
|
19766
|
+
import { readFile as readFile24 } from "node:fs/promises";
|
|
19727
19767
|
import path64 from "node:path";
|
|
19728
19768
|
import { promisify } from "node:util";
|
|
19729
19769
|
var execFileAsync = promisify(execFile);
|
|
@@ -19757,7 +19797,7 @@ async function gitHasUncommittedChanges(dir) {
|
|
|
19757
19797
|
async function defaultName(dir) {
|
|
19758
19798
|
try {
|
|
19759
19799
|
const parsed = JSON.parse(
|
|
19760
|
-
await
|
|
19800
|
+
await readFile24(path64.join(dir, "package.json"), "utf8")
|
|
19761
19801
|
);
|
|
19762
19802
|
if (typeof parsed.name === "string" && parsed.name.trim())
|
|
19763
19803
|
return parsed.name.replace(/^@[^/]+\//, "");
|
|
@@ -21019,7 +21059,7 @@ async function upsertGatewayPlansFromManifest(client, config2, projectId, plans,
|
|
|
21019
21059
|
}
|
|
21020
21060
|
|
|
21021
21061
|
// src/cli/platform/helpers/openapi-gateway-servers.ts
|
|
21022
|
-
import { mkdir as mkdir16, readFile as
|
|
21062
|
+
import { mkdir as mkdir16, readFile as readFile25, writeFile as writeFile19 } from "node:fs/promises";
|
|
21023
21063
|
import path67 from "node:path";
|
|
21024
21064
|
import YAML from "yaml";
|
|
21025
21065
|
var GATEWAY_URL_ENV_KEY = "APITOGO_GATEWAY_URL";
|
|
@@ -21051,7 +21091,7 @@ async function resolveProjectGatewayUrl(client, projectId) {
|
|
|
21051
21091
|
return null;
|
|
21052
21092
|
}
|
|
21053
21093
|
async function readOpenApiDocument(filePath) {
|
|
21054
|
-
const content = await
|
|
21094
|
+
const content = await readFile25(filePath, "utf8");
|
|
21055
21095
|
const ext = path67.extname(filePath).toLowerCase();
|
|
21056
21096
|
const parsed = ext === ".json" ? JSON.parse(content) : YAML.parse(content);
|
|
21057
21097
|
if (!parsed || typeof parsed !== "object" || Array.isArray(parsed)) {
|
|
@@ -21080,7 +21120,7 @@ async function pointSiteApisAtPublishOpenApi(siteDirectory, relativeInput) {
|
|
|
21080
21120
|
path67.resolve(siteDirectory),
|
|
21081
21121
|
APITOGO_CONFIG_FILENAME2
|
|
21082
21122
|
);
|
|
21083
|
-
const raw = await
|
|
21123
|
+
const raw = await readFile25(configPath, "utf8");
|
|
21084
21124
|
const config2 = JSON.parse(raw);
|
|
21085
21125
|
const previousApis = config2.apis;
|
|
21086
21126
|
const previousBackend = config2.backend;
|
|
@@ -21097,7 +21137,7 @@ async function pointSiteApisAtPublishOpenApi(siteDirectory, relativeInput) {
|
|
|
21097
21137
|
`, "utf8");
|
|
21098
21138
|
return {
|
|
21099
21139
|
restore: async () => {
|
|
21100
|
-
const currentRaw = await
|
|
21140
|
+
const currentRaw = await readFile25(configPath, "utf8");
|
|
21101
21141
|
const current = JSON.parse(currentRaw);
|
|
21102
21142
|
if (previousApis === void 0) {
|
|
21103
21143
|
delete current.apis;
|
|
@@ -21132,7 +21172,7 @@ async function prepareOpenApiServersForGatewayBuild(options) {
|
|
|
21132
21172
|
);
|
|
21133
21173
|
if (!openApiPath) {
|
|
21134
21174
|
try {
|
|
21135
|
-
const raw = await
|
|
21175
|
+
const raw = await readFile25(
|
|
21136
21176
|
path67.join(siteDirectory, APITOGO_CONFIG_FILENAME2),
|
|
21137
21177
|
"utf8"
|
|
21138
21178
|
);
|
|
@@ -21206,7 +21246,7 @@ function collectManifestPublicActionKeys(gateway) {
|
|
|
21206
21246
|
}
|
|
21207
21247
|
|
|
21208
21248
|
// src/cli/platform/helpers/publish-ledger.ts
|
|
21209
|
-
import { mkdir as mkdir17, readFile as
|
|
21249
|
+
import { mkdir as mkdir17, readFile as readFile26, writeFile as writeFile20 } from "node:fs/promises";
|
|
21210
21250
|
import path68 from "node:path";
|
|
21211
21251
|
var PUBLISH_LEDGER_RELATIVE_PATH = ".apitogo/publish-state.json";
|
|
21212
21252
|
function publishLedgerPath(siteDirectory) {
|
|
@@ -21215,7 +21255,7 @@ function publishLedgerPath(siteDirectory) {
|
|
|
21215
21255
|
async function readPublishLedger(siteDirectory) {
|
|
21216
21256
|
const filePath = publishLedgerPath(siteDirectory);
|
|
21217
21257
|
try {
|
|
21218
|
-
const raw = await
|
|
21258
|
+
const raw = await readFile26(filePath, "utf8");
|
|
21219
21259
|
const parsed = JSON.parse(raw);
|
|
21220
21260
|
if (parsed?.version !== 1 || !Array.isArray(parsed.steps)) {
|
|
21221
21261
|
return null;
|
|
@@ -23486,7 +23526,7 @@ async function resolveProjectIdForPublish(client, config2, args, wait, progress,
|
|
|
23486
23526
|
import path75 from "node:path";
|
|
23487
23527
|
|
|
23488
23528
|
// src/cli/platform/helpers/dev-portal-site-api-url.ts
|
|
23489
|
-
import { readdir as readdir5, readFile as
|
|
23529
|
+
import { readdir as readdir5, readFile as readFile27, writeFile as writeFile21 } from "node:fs/promises";
|
|
23490
23530
|
import path72 from "node:path";
|
|
23491
23531
|
var SITE_API_BASE_URL_ENV_KEY = "VITE_APITOGO_AUTHENTICATION_API_BASE_URL";
|
|
23492
23532
|
var PLACEHOLDER_HOST_MARKERS = [
|
|
@@ -23511,7 +23551,7 @@ async function readSiteApiBaseUrl(sourceDirectory) {
|
|
|
23511
23551
|
const resolved = path72.resolve(sourceDirectory);
|
|
23512
23552
|
for (const envFile of [".env", ".env.production"]) {
|
|
23513
23553
|
try {
|
|
23514
|
-
const content = await
|
|
23554
|
+
const content = await readFile27(path72.join(resolved, envFile), "utf8");
|
|
23515
23555
|
const lines = [...content.matchAll(ENV_LINE_GLOBAL_RE)];
|
|
23516
23556
|
if (lines.length === 0) {
|
|
23517
23557
|
continue;
|
|
@@ -23542,7 +23582,7 @@ async function patchSiteApiBaseUrl(sourceDirectory, apiBaseUrl) {
|
|
|
23542
23582
|
for (const envFile of [".env.production", ".env"]) {
|
|
23543
23583
|
const envPath = path72.join(resolved, envFile);
|
|
23544
23584
|
try {
|
|
23545
|
-
const content = await
|
|
23585
|
+
const content = await readFile27(envPath, "utf8");
|
|
23546
23586
|
const withoutAssignments = content.replace(ENV_LINE_GLOBAL_RE, "").replace(/\n{3,}/g, "\n\n").trimEnd();
|
|
23547
23587
|
const patched = withoutAssignments ? `${withoutAssignments}
|
|
23548
23588
|
${line2}
|
|
@@ -23622,7 +23662,7 @@ async function assertDeployableDistHasLiveApiBaseUrl(distDirectory, expectedApiB
|
|
|
23622
23662
|
let found = false;
|
|
23623
23663
|
let foundPlaceholder = false;
|
|
23624
23664
|
for await (const file of walkFiles(dist)) {
|
|
23625
|
-
const content = await
|
|
23665
|
+
const content = await readFile27(file, "utf8");
|
|
23626
23666
|
if (content.includes(needle)) {
|
|
23627
23667
|
found = true;
|
|
23628
23668
|
}
|
|
@@ -26247,7 +26287,7 @@ import path79 from "node:path";
|
|
|
26247
26287
|
|
|
26248
26288
|
// src/cli/deploy/gateway.ts
|
|
26249
26289
|
import { createHash as createHash4 } from "node:crypto";
|
|
26250
|
-
import { readFile as
|
|
26290
|
+
import { readFile as readFile28 } from "node:fs/promises";
|
|
26251
26291
|
init_invariant();
|
|
26252
26292
|
var GatewayDeployError = class extends ApitogoError {
|
|
26253
26293
|
constructor(code, message, developerHint) {
|
|
@@ -26285,7 +26325,7 @@ async function readSpec(gateway) {
|
|
|
26285
26325
|
"Add one to gateway.specs in the config."
|
|
26286
26326
|
);
|
|
26287
26327
|
try {
|
|
26288
|
-
return await
|
|
26328
|
+
return await readFile28(file);
|
|
26289
26329
|
} catch {
|
|
26290
26330
|
throw new GatewayDeployError(
|
|
26291
26331
|
"GATEWAY_SPEC_UNREADABLE",
|
package/package.json
CHANGED
package/src/config/v2/wrapper.ts
CHANGED
|
@@ -41,6 +41,18 @@ export function contentGlob(configDir: string, glob: string): string {
|
|
|
41
41
|
return `${negated ? "!" : ""}/${CONTENT_LINK}/${relative}`;
|
|
42
42
|
}
|
|
43
43
|
|
|
44
|
+
/**
|
|
45
|
+
* A project file as the generated site root sees it: `content/<path in the project>`, which the build resolves against
|
|
46
|
+
* the site root. The generated config is imported by the portal's code, so an absolute path would end up in the public
|
|
47
|
+
* bundle (API-127). A file outside the project has no such path and keeps its absolute one.
|
|
48
|
+
*/
|
|
49
|
+
export function contentFile(configDir: string, file: string): string {
|
|
50
|
+
const relative = path.relative(configDir, file);
|
|
51
|
+
if (relative.startsWith("..") || path.isAbsolute(relative))
|
|
52
|
+
return file.split(path.sep).join("/");
|
|
53
|
+
return `${CONTENT_LINK}/${relative.split(path.sep).join("/")}`;
|
|
54
|
+
}
|
|
55
|
+
|
|
44
56
|
/** Capabilities of the plans service that put something on the console. Any one of them registers the plans plugin. */
|
|
45
57
|
const PLANS_CONSOLE_CAPABILITIES = [
|
|
46
58
|
"catalog",
|
|
@@ -334,14 +346,14 @@ export function buildSiteConfig(
|
|
|
334
346
|
},
|
|
335
347
|
modules: {
|
|
336
348
|
docs: { enabled: plan.docs },
|
|
337
|
-
// A custom home page (`portal.landing`) is served at `/`; the build imports the component
|
|
349
|
+
// A custom home page (`portal.landing`) is served at `/`; the build imports the component through the content link.
|
|
338
350
|
...(portal?.landing
|
|
339
351
|
? {
|
|
340
352
|
landing: {
|
|
341
353
|
enabled: true,
|
|
342
354
|
path: "/",
|
|
343
355
|
layout: "landing",
|
|
344
|
-
page: portal.landing
|
|
356
|
+
page: contentFile(resolved.configDir, portal.landing),
|
|
345
357
|
},
|
|
346
358
|
}
|
|
347
359
|
: {}),
|