turnzero 0.14.0 → 0.16.0-next.1
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/turnzero-cloud.mjs +60 -51
- package/package.json +1 -1
package/dist/turnzero-cloud.mjs
CHANGED
|
@@ -232,16 +232,6 @@ var SCAFFOLD_TEMPLATE_ENTRIES = Object.freeze({
|
|
|
232
232
|
["database", "account", "ai_allowance"].map((entry) => Object.freeze({ entry, writes: "web app with sign-in, a database, and the AI allowance" }))
|
|
233
233
|
)
|
|
234
234
|
});
|
|
235
|
-
var scaffoldLineOf = (call) => commandLineOf(call.origin, SCAFFOLD_SUBCOMMAND, {
|
|
236
|
-
options: [
|
|
237
|
-
...call.template !== void 0 ? [[SCAFFOLD_OPTION.template, call.template]] : [],
|
|
238
|
-
...call.resource !== void 0 ? [[SCAFFOLD_OPTION.resource, call.resource]] : [],
|
|
239
|
-
...call.singular !== void 0 ? [[SCAFFOLD_OPTION.singular, call.singular]] : [],
|
|
240
|
-
...call.fields !== void 0 ? [[SCAFFOLD_OPTION.fields, `"${call.fields}"`]] : []
|
|
241
|
-
],
|
|
242
|
-
...call.origin !== DEFAULT_COMMAND_ORIGIN ? { origin: call.origin } : {},
|
|
243
|
-
...call.path !== void 0 ? { path: call.path } : {}
|
|
244
|
-
});
|
|
245
235
|
var CODE_CHALLENGE_FORM = /^[A-Za-z0-9_-]{43}$/;
|
|
246
236
|
var CODE_VERIFIER_FORM = /^[A-Za-z0-9._~-]{43,128}$/;
|
|
247
237
|
var codeChallengeOf = (verifier) => createHash("sha256").update(verifier).digest("base64url");
|
|
@@ -2946,10 +2936,11 @@ import { join as join4 } from "node:path";
|
|
|
2946
2936
|
import * as zlib from "node:zlib";
|
|
2947
2937
|
import { deflateRawSync, inflateRawSync as inflateRawSync2 } from "node:zlib";
|
|
2948
2938
|
var LEFT_OUT_NAMES = Object.freeze(["node_modules", ".git"]);
|
|
2949
|
-
var
|
|
2939
|
+
var environmentFileName = (name) => {
|
|
2950
2940
|
const lower = name.toLowerCase();
|
|
2951
|
-
return
|
|
2941
|
+
return lower === ".env" || lower.startsWith(".env.");
|
|
2952
2942
|
};
|
|
2943
|
+
var leftOutName = (name) => LEFT_OUT_NAMES.includes(name.toLowerCase()) || environmentFileName(name);
|
|
2953
2944
|
var FIXED_DOS_DATE = 0 << 9 | 1 << 5 | 1;
|
|
2954
2945
|
var FIXED_DOS_TIME = 0;
|
|
2955
2946
|
var UTF8_NAME_FLAG = 2048;
|
|
@@ -4776,32 +4767,25 @@ var withDependency = (text, parsed, name, spec) => {
|
|
|
4776
4767
|
return `${JSON.stringify({ ...parsed, dependencies: sorted }, null, indent)}
|
|
4777
4768
|
`;
|
|
4778
4769
|
};
|
|
4779
|
-
var
|
|
4780
|
-
var
|
|
4781
|
-
|
|
4782
|
-
|
|
4783
|
-
|
|
4784
|
-
var
|
|
4785
|
-
|
|
4786
|
-
var noPackageWayOnOf = (io2, options, name) => {
|
|
4787
|
-
const template = templateTakingOf(name);
|
|
4788
|
-
const taking = template === null ? void 0 : SCAFFOLD_TEMPLATE_ENTRIES[template].find((row) => row.entry === name);
|
|
4789
|
-
if (template === null || taking === void 0) return OTHER_WAY_ON;
|
|
4790
|
-
const app = join7(options.root, "app");
|
|
4791
|
-
let empty;
|
|
4770
|
+
var MADE_FOLDER = "app";
|
|
4771
|
+
var NPM_NAME_LIMIT = 214;
|
|
4772
|
+
var packageNameOf = (folder) => folder.toLowerCase().replace(/[^a-z0-9._~-]+/g, "-").replace(/^[._-]+/, "").slice(0, NPM_NAME_LIMIT).replace(/[.-]+$/, "") || MADE_FOLDER;
|
|
4773
|
+
var madePackageFileOf = (made, packageName, spec) => `${JSON.stringify({ name: made.name, private: true, ...made.module ? { type: "module" } : {}, dependencies: { [packageName]: spec } }, null, 2)}
|
|
4774
|
+
`;
|
|
4775
|
+
var moduleTypeOf = (bytes) => {
|
|
4776
|
+
if (bytes === void 0) return false;
|
|
4792
4777
|
try {
|
|
4793
|
-
|
|
4794
|
-
empty = standing === null || standing.folder && io2.listFolder(app)?.length === 0;
|
|
4778
|
+
return JSON.parse(jsonTextOf(bytes))?.type === "module";
|
|
4795
4779
|
} catch {
|
|
4796
|
-
|
|
4780
|
+
return false;
|
|
4797
4781
|
}
|
|
4798
|
-
if (!empty) return OTHER_WAY_ON;
|
|
4799
|
-
const line = machineLineOf(scaffoldLineOf({ origin: options.origin, template }), { windows: io2.windows ?? LINES_IN_WINDOWS_FORM, npx: ranThroughNpx({ env: io2.env ?? {}, ranThroughNpx: io2.ranThroughNpx }) }, options.origin);
|
|
4800
|
-
return {
|
|
4801
|
-
clause: MAKE_OWN_PACKAGE_FILE,
|
|
4802
|
-
after: `For a new ${taking.writes}, run the scaffold line at the project's root instead, which writes the application and takes this entry: ${line}`
|
|
4803
|
-
};
|
|
4804
4782
|
};
|
|
4783
|
+
var ofModuleType = (plan, name) => {
|
|
4784
|
+
const made = { name: plan.made?.name ?? MADE_FOLDER, module: true };
|
|
4785
|
+
return { ...plan, made, declared: madePackageFileOf(made, `${PACKAGE_SCOPE}${name}`, plan.declaredAt ?? `file:lib/${name}`) };
|
|
4786
|
+
};
|
|
4787
|
+
var MADE_LINE_HEAD = "made: ";
|
|
4788
|
+
var madeLineOf = (made) => `${MADE_LINE_HEAD}${MADE_FOLDER}/package.json, since neither app/package.json nor the project root's package.json stood: private, named ${made.name}${made.module ? ", of type module" : ""}, with no scripts.`;
|
|
4805
4789
|
var BYTE_ORDER_MARK3 = "\uFEFF";
|
|
4806
4790
|
var jsonTextOf = (bytes) => {
|
|
4807
4791
|
const text = bytes.toString("utf8");
|
|
@@ -4817,16 +4801,29 @@ var openingCharacterClauseOf = (text) => {
|
|
|
4817
4801
|
return control ? `: the file opens with ${point}, a control character` : "";
|
|
4818
4802
|
};
|
|
4819
4803
|
var applicationFolderOf = (io2, root) => [join7(root, "app"), root].find((folder) => io2.stat(join7(folder, "package.json"))?.folder === false) ?? null;
|
|
4820
|
-
var copyPlanOf = (io2, root, library, name
|
|
4804
|
+
var copyPlanOf = (io2, root, library, name) => {
|
|
4821
4805
|
const shown2 = shownFrom(root);
|
|
4822
4806
|
if (name.includes("/")) return { refusal: `The entry ${LIBRARY_OPTION.entry} names carries compiled modules under a name that holds a slash, which an npm package cannot take. ${NOTHING_WRITTEN2}` };
|
|
4823
4807
|
const application = applicationFolderOf(io2, root);
|
|
4824
4808
|
if (application === null) {
|
|
4825
|
-
const
|
|
4826
|
-
|
|
4827
|
-
|
|
4828
|
-
|
|
4829
|
-
}
|
|
4809
|
+
const app = join7(root, MADE_FOLDER);
|
|
4810
|
+
const standing = io2.stat(app);
|
|
4811
|
+
if (standing !== null && !standing.folder || danglingLinkAt(io2, root, MADE_FOLDER)) {
|
|
4812
|
+
return { refusal: `Something that is no folder stands at ${MADE_FOLDER}, where the take would make the application's package.json. ${NOTHING_WRITTEN2}` };
|
|
4813
|
+
}
|
|
4814
|
+
const copy2 = join7(app, "lib", name);
|
|
4815
|
+
const madeFile = join7(app, "package.json");
|
|
4816
|
+
if (io2.stat(madeFile) !== null || standing !== null && danglingLinkAt(io2, app, "package.json")) {
|
|
4817
|
+
return { refusal: `Something that is no package file stands at ${MADE_FOLDER}/package.json, where the take would make it. ${NOTHING_WRITTEN2}` };
|
|
4818
|
+
}
|
|
4819
|
+
if (copy2 === library || inside(copy2, library) || inside(library, copy2) || inside(library, madeFile)) {
|
|
4820
|
+
return {
|
|
4821
|
+
refusal: `The take would make ${MADE_FOLDER}/package.json and place the copy at ${shown2(copy2)}, inside the project's library folder, which a take never writes. Make the application's package.json first, then run this line again. ${NOTHING_WRITTEN2}`
|
|
4822
|
+
};
|
|
4823
|
+
}
|
|
4824
|
+
const made = { name: packageNameOf(basename2(resolve10(root))), module: false };
|
|
4825
|
+
const declaredAt2 = `file:lib/${name}`;
|
|
4826
|
+
return { application: app, copy: copy2, declared: madePackageFileOf(made, `${PACKAGE_SCOPE}${name}`, declaredAt2), declaredAt: declaredAt2, made };
|
|
4830
4827
|
}
|
|
4831
4828
|
const packageFile = join7(application, "package.json");
|
|
4832
4829
|
const read2 = io2.readFile(packageFile);
|
|
@@ -4917,6 +4914,7 @@ var shownJson = (text) => [...text].map((character) => shownWhole(character) ===
|
|
|
4917
4914
|
var packagesLineOf = (rows) => `${PACKAGES_LINE_HEAD}${shownJson(JSON.stringify(rows))}`;
|
|
4918
4915
|
var applicationManifestPartialOf = (at) => `${at}.partial`;
|
|
4919
4916
|
var PARTIAL_LINK_SENTENCE = writtenLinkSentence(`The file the application manifest is written to first, ${MANIFEST_FILE2}.partial beside it,`);
|
|
4917
|
+
var danglingLinkAt = (io2, folder, name) => io2.stat(join7(folder, name)) === null && (io2.listFolder(folder) ?? []).some((held) => held.toLowerCase() === name.toLowerCase() && io2.stat(join7(folder, held)) === null);
|
|
4920
4918
|
var linkStandsAt = (io2, path) => {
|
|
4921
4919
|
const name = basename2(path);
|
|
4922
4920
|
if (!(io2.listFolder(dirname4(path)) ?? []).includes(name)) return false;
|
|
@@ -4929,8 +4927,7 @@ var writtenNameRefusalOf = (io2, holder, names) => {
|
|
|
4929
4927
|
const through = names.find(([, at]) => writesThroughLink(io2, holder, at));
|
|
4930
4928
|
return through === void 0 ? null : writtenLinkSentence(through[0]);
|
|
4931
4929
|
};
|
|
4932
|
-
var applicationManifestOf = (io2, root, library) => {
|
|
4933
|
-
const folder = applicationFolderOf(io2, root);
|
|
4930
|
+
var applicationManifestOf = (io2, root, library, folder = applicationFolderOf(io2, root)) => {
|
|
4934
4931
|
if (folder === null) return { at: null, unwritten: "no_folder" };
|
|
4935
4932
|
const at = join7(folder, MANIFEST_FILE2);
|
|
4936
4933
|
const standing = io2.stat(at);
|
|
@@ -5037,8 +5034,9 @@ async function readTake(io2, options, userAgent, planOf, planeChecked = false) {
|
|
|
5037
5034
|
if (actual !== file.sha256) return refuse(`${LIBRARY_FOLDER}/${shownName(file.path)}: SHA-256 ${actual} is not the listed value ${file.sha256}. ${NOTHING_WRITTEN2}`);
|
|
5038
5035
|
bytes.set(file.path, read2.bytes);
|
|
5039
5036
|
}
|
|
5037
|
+
const planned = plan !== null && plan.made !== void 0 && moduleTypeOf(bytes.get(`${entry.path}/package.json`)) ? ofModuleType(plan, entry.name) : plan;
|
|
5040
5038
|
const packages = packagesOf(manifestTextOf(manifest.rows, { name: entry.name, version: entry.version, closure_hash: entry.closure_hash, source_commit: entry.source_commit, fetched_at: "" }));
|
|
5041
|
-
return { entry, library, fresh: found.fresh, entryFolder, rows: manifest.rows, manifestStood: manifest.stood, compiled, plan, bytes, packages };
|
|
5039
|
+
return { entry, library, fresh: found.fresh, entryFolder, rows: manifest.rows, manifestStood: manifest.stood, compiled, plan: planned, bytes, packages };
|
|
5042
5040
|
}
|
|
5043
5041
|
function writeTake(io2, root, { entry, library, entryFolder, rows, manifestStood, compiled, plan, bytes }) {
|
|
5044
5042
|
const shown2 = shownFrom(root);
|
|
@@ -5086,6 +5084,7 @@ function writeTake(io2, root, { entry, library, entryFolder, rows, manifestStood
|
|
|
5086
5084
|
);
|
|
5087
5085
|
const packageFile = join7(plan.application, "package.json");
|
|
5088
5086
|
if (plan.declared !== null) io2.writeFile(packageFile, plan.declared);
|
|
5087
|
+
if (plan.made !== void 0) io2.print(madeLineOf(plan.made));
|
|
5089
5088
|
io2.print(
|
|
5090
5089
|
`copied: package.json and lib/ to ${shown2(plan.copy)}, ${plan.declaredAt !== null ? `declared as ${PACKAGE_SCOPE}${entry.name} at ${plan.declaredAt} in` : `its declaration kept in`} ${shown2(packageFile)}.`
|
|
5091
5090
|
);
|
|
@@ -5137,9 +5136,9 @@ async function libraryTake(call, io2) {
|
|
|
5137
5136
|
}
|
|
5138
5137
|
const fromApplication = applicationFolderRefusalOf(io2, options);
|
|
5139
5138
|
if (fromApplication !== null) return refuse(fromApplication);
|
|
5140
|
-
const checked = await readTake(io2, options, agent.userAgent, (library, name) => copyPlanOf(io2, options.root, library, name
|
|
5139
|
+
const checked = await readTake(io2, options, agent.userAgent, (library, name) => copyPlanOf(io2, options.root, library, name));
|
|
5141
5140
|
if ("lines" in checked) return refuse(...checked.lines);
|
|
5142
|
-
const application = applicationManifestOf(io2, options.root, checked.library);
|
|
5141
|
+
const application = applicationManifestOf(io2, options.root, checked.library, checked.plan?.application ?? applicationFolderOf(io2, options.root));
|
|
5143
5142
|
if ("refusal" in application) return refuse(application.refusal);
|
|
5144
5143
|
const manifestText = writeTake(io2, options.root, checked);
|
|
5145
5144
|
const written = writeApplicationManifest(io2, application, packagesOf(manifestText));
|
|
@@ -5616,6 +5615,7 @@ var startUpgradeCheck = (io2, subcommand, named, running) => {
|
|
|
5616
5615
|
};
|
|
5617
5616
|
|
|
5618
5617
|
// src/turnzero_cloud_command/provision.ts
|
|
5618
|
+
import { basename as basename3 } from "node:path";
|
|
5619
5619
|
var PROVISION_OPTIONS = Object.freeze([
|
|
5620
5620
|
{
|
|
5621
5621
|
name: PROVISION_OPTION.application,
|
|
@@ -5627,7 +5627,7 @@ var PROVISION_OPTIONS = Object.freeze([
|
|
|
5627
5627
|
name: PROVISION_OPTION.envFile,
|
|
5628
5628
|
value: "<file>",
|
|
5629
5629
|
required: false,
|
|
5630
|
-
description: `The environment file to write. Where absent, ${ENVIRONMENT_FILE_NAME} in the folder the command runs in. An existing file keeps every line the command does not set.`
|
|
5630
|
+
description: `The environment file to write, named ${ENVIRONMENT_FILE_NAME} or ${ENVIRONMENT_FILE_NAME}.<name>, the names every zip the command builds leaves out. Where absent, ${ENVIRONMENT_FILE_NAME} in the folder the command runs in. An existing file keeps every line the command does not set.`
|
|
5631
5631
|
},
|
|
5632
5632
|
{
|
|
5633
5633
|
name: PROVISION_OPTION.origin,
|
|
@@ -5650,7 +5650,8 @@ var remintAgainSentence = (kind) => {
|
|
|
5650
5650
|
const steps = againSteps(kind);
|
|
5651
5651
|
return `${steps[0].toUpperCase()}${steps.slice(1)}: it re-mints both credentials and writes the file.`;
|
|
5652
5652
|
};
|
|
5653
|
-
var
|
|
5653
|
+
var envFileNameRefusalOf = (standing) => `${PROVISION_OPTION.envFile} names the environment file ${ENVIRONMENT_FILE_NAME} or ${ENVIRONMENT_FILE_NAME}.<name>, the names every zip the command or deploy_files builds leaves out, so the credentials it holds never ride one.${standing ? ` A file stands at the name given, and an earlier run may have written credentials into it: move its lines into ${ENVIRONMENT_FILE_NAME} and delete it.` : ""} ${NOTHING_REMINTED}`;
|
|
5654
|
+
var provisionOptionsOf = (call, cwd, stands = () => false) => {
|
|
5654
5655
|
const application = call.named[PROVISION_OPTION.application];
|
|
5655
5656
|
if (application === void 0 || !UPLOAD_ID.test(application)) {
|
|
5656
5657
|
return {
|
|
@@ -5659,7 +5660,9 @@ var provisionOptionsOf = (call, cwd) => {
|
|
|
5659
5660
|
}
|
|
5660
5661
|
const origin = commandOriginOf(call.named[PROVISION_OPTION.origin] ?? DEFAULT_COMMAND_ORIGIN);
|
|
5661
5662
|
if ("refusal" in origin) return origin;
|
|
5662
|
-
|
|
5663
|
+
const envFile = environmentFileOf(cwd, call.named[PROVISION_OPTION.envFile]);
|
|
5664
|
+
if (!environmentFileName(basename3(envFile))) return { refusal: envFileNameRefusalOf(stands(envFile)) };
|
|
5665
|
+
return { application, envFile, origin: origin.origin };
|
|
5663
5666
|
};
|
|
5664
5667
|
var charactersOf = (value) => `<${value.length} characters>`;
|
|
5665
5668
|
var transportText = (error) => {
|
|
@@ -5750,7 +5753,13 @@ var remintUnknownSentence = (which) => `Whether the development ${which} credent
|
|
|
5750
5753
|
var DATABASE_VALUE_LOST = "The development database credential was re-minted and its value was not written, so a connection setting an earlier run wrote no longer connects.";
|
|
5751
5754
|
var PLATFORM_VALUE_LOST = `The development platform credential was re-minted and its value was not written, so a ${LOCAL_RUN_SETTING.platformCredential} an earlier run wrote is revoked.`;
|
|
5752
5755
|
async function provision(call, io2) {
|
|
5753
|
-
const options = provisionOptionsOf(call, io2.cwd)
|
|
5756
|
+
const options = provisionOptionsOf(call, io2.cwd, (path) => {
|
|
5757
|
+
try {
|
|
5758
|
+
return io2.stat(path)?.folder === false;
|
|
5759
|
+
} catch {
|
|
5760
|
+
return false;
|
|
5761
|
+
}
|
|
5762
|
+
});
|
|
5754
5763
|
if ("refusal" in options) {
|
|
5755
5764
|
io2.print(options.refusal);
|
|
5756
5765
|
return COMMAND_STATUS.nothing_started;
|
|
@@ -5904,7 +5913,7 @@ var PROVISION_ROW = Object.freeze({
|
|
|
5904
5913
|
});
|
|
5905
5914
|
|
|
5906
5915
|
// src/turnzero_cloud_command/scaffold.ts
|
|
5907
|
-
import { basename as
|
|
5916
|
+
import { basename as basename4, dirname as dirname5, isAbsolute as isAbsolute5, join as join8, relative as relative5, resolve as resolve11 } from "node:path";
|
|
5908
5917
|
|
|
5909
5918
|
// src/turnzero_cloud_command/scaffold_template.ts
|
|
5910
5919
|
var SCAFFOLD_TEMPLATE_FILES = Object.freeze({
|
|
@@ -7832,7 +7841,7 @@ var folderRefusalOf = (io2, options, files, takeLines) => {
|
|
|
7832
7841
|
const { root } = options;
|
|
7833
7842
|
for (let at = root; ; at = dirname5(at)) {
|
|
7834
7843
|
const standing2 = io2.stat(at);
|
|
7835
|
-
const what = standing2 !== null ? standing2.folder ? null : "a file" : danglingAt(io2, dirname5(at),
|
|
7844
|
+
const what = standing2 !== null ? standing2.folder ? null : "a file" : danglingAt(io2, dirname5(at), basename4(at)) ? "a link whose target does not stand" : null;
|
|
7836
7845
|
if (what !== null) {
|
|
7837
7846
|
return [`${options.named ? `${SCAFFOLD_OPTION.path} names ${what}, or a place under one` : `The folder the line runs in is ${what}, or stands under one`}, where the project's root stands or is made. ${NOTHING_WRITTEN2}`];
|
|
7838
7847
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "turnzero",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.16.0-next.1",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"description": "The Turn Zero Cloud command, which an AI coding tool runs on your machine to deploy an application, store a secret, upload a file, download an export, take a library entry, write a local run's settings, start the application locally, and scaffold a new service from a template.",
|
|
6
6
|
"license": "Apache-2.0",
|