turnzero 0.25.0 → 0.25.1-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.
@@ -8618,8 +8618,66 @@ var applicationStandsLines = (template, takeLines) => {
8618
8618
  STANDS_DEPLOY_LINE
8619
8619
  ];
8620
8620
  };
8621
+ var TAKE_MADE_FILES = Object.freeze({
8622
+ "package.json": "file",
8623
+ lib: "folder",
8624
+ "package-lock.json": "file",
8625
+ node_modules: "folder"
8626
+ });
8627
+ var TAKE_MADE_FILE_LIMIT = 65536;
8628
+ var LIBRARY_COPIES = "lib";
8629
+ var takeMadeEntriesOf = (io2, app) => {
8630
+ try {
8631
+ const names = io2.listFolder(app) ?? [];
8632
+ if (!names.includes("package.json") || !names.includes(LIBRARY_COPIES)) return null;
8633
+ for (const name2 of names) {
8634
+ const kind = Object.hasOwn(TAKE_MADE_FILES, name2) ? TAKE_MADE_FILES[name2] : void 0;
8635
+ const standing = io2.stat(join10(app, name2));
8636
+ if (kind === void 0 || standing === null || standing.folder !== (kind === "folder")) return null;
8637
+ }
8638
+ const packageFile = join10(app, "package.json");
8639
+ if ((io2.stat(packageFile)?.size ?? Infinity) > TAKE_MADE_FILE_LIMIT) return null;
8640
+ const parsed = JSON.parse(jsonTextOf(io2.readFile(packageFile)));
8641
+ if (parsed === null || typeof parsed !== "object" || Array.isArray(parsed)) return null;
8642
+ const members = parsed;
8643
+ const { name, private: privateFlag, dependencies, ...rest } = members;
8644
+ const { type, ...others } = rest;
8645
+ if (Object.keys(others).length > 0 || typeof name !== "string" || privateFlag !== true) return null;
8646
+ if (Object.hasOwn(members, "type") && type !== "module") return null;
8647
+ if (dependencies === null || typeof dependencies !== "object" || Array.isArray(dependencies)) return null;
8648
+ const entries = [];
8649
+ for (const [packageName, spec] of Object.entries(dependencies)) {
8650
+ const entry = packageName.slice(PACKAGE_SCOPE.length);
8651
+ if (!packageName.startsWith(PACKAGE_SCOPE) || entry.includes("/") || !LIBRARY_ENTRY_NAME_FORM.test(entry) || spec !== `file:${LIBRARY_COPIES}/${entry}`) return null;
8652
+ entries.push(entry);
8653
+ }
8654
+ const lib = join10(app, LIBRARY_COPIES);
8655
+ const copies = io2.listFolder(lib) ?? [];
8656
+ if (entries.length === 0 || copies.length !== entries.length || !copies.every((copy) => entries.includes(copy))) return null;
8657
+ return entries.every((entry) => io2.stat(join10(lib, entry))?.folder === true) ? entries : null;
8658
+ } catch {
8659
+ return null;
8660
+ }
8661
+ };
8662
+ var takeMadeLines = (template, entries, lineOf) => {
8663
+ const own = new Set(TEMPLATE_FACTS[template].takes.map((take) => take.entry));
8664
+ const again = entries.filter((entry) => !own.has(entry));
8665
+ const first = `The project's root holds ${APPLICATION_FOLDER}/ with only what a library take made, its package.json and the copies under ${LIBRARY_COPIES}/, and ${SCAFFOLD_SUBCOMMAND} writes into no ${APPLICATION_FOLDER}/ that holds files. ${NOTHING_WRITTEN2}`;
8666
+ const opening = `To start a new application here, delete ${APPLICATION_FOLDER}/, then run the same line again`;
8667
+ if (again.length === 0) {
8668
+ const taken = entries.length === 1 ? `the ${entries[0]} entry` : `the ${listedAnd(entries)} entries`;
8669
+ return [first, `${opening}, which takes ${taken} itself.`];
8670
+ }
8671
+ const lines = again.map(lineOf);
8672
+ if (again.length === 1) return [first, `${opening}, then run this line at the project's root, which takes the ${again[0]} entry again into the new ${APPLICATION_FOLDER}/: ${lines[0]}`];
8673
+ return [
8674
+ first,
8675
+ `${opening}, then run each of these ${LINE_COUNT_WORDS[lines.length] ?? lines.length} lines at the project's root, in order, which take the ${listedAnd(again)} entries again into the new ${APPLICATION_FOLDER}/:`,
8676
+ ...lines
8677
+ ];
8678
+ };
8621
8679
  var STAGE_NOT_OWN = `Something that is not this run's own stands at ${STAGE_FOLDER} in the project's root, the name the scaffold writes under, an earlier run's files under another template or another resource name among it: move or remove ${STAGE_FOLDER}, then run the line again. ${NOTHING_WRITTEN2}`;
8622
- var folderRefusalOf = (io2, options, files, takeLines) => {
8680
+ var folderRefusalOf = (io2, options, files, takeLines, lineOf) => {
8623
8681
  const { root } = options;
8624
8682
  for (let at = root; ; at = dirname6(at)) {
8625
8683
  const standing2 = io2.stat(at);
@@ -8634,7 +8692,10 @@ var folderRefusalOf = (io2, options, files, takeLines) => {
8634
8692
  const notOwn = STAGE_NOT_OWN;
8635
8693
  const standing = io2.stat(app);
8636
8694
  if (standing === null ? danglingAt(io2, root, APPLICATION_FOLDER) : !standing.folder) return [noFolderSentence(APPLICATION_FOLDER, "the scaffold writes the application")];
8637
- if (standing !== null && (io2.listFolder(app) ?? []).length > 0) return applicationStandsLines(options.template, takeLines);
8695
+ if (standing !== null && (io2.listFolder(app) ?? []).length > 0) {
8696
+ const taken = takeMadeEntriesOf(io2, app);
8697
+ return taken !== null ? takeMadeLines(options.template, taken, lineOf) : applicationStandsLines(options.template, takeLines);
8698
+ }
8638
8699
  if (!heldInside(io2, root, app)) return [scaffoldLinkSentence(`The application's folder, ${APPLICATION_FOLDER}/,`)];
8639
8700
  const staged = io2.stat(stage);
8640
8701
  if (staged === null && danglingAt(io2, root, STAGE_FOLDER)) return [notOwn];
@@ -8814,8 +8875,10 @@ async function scaffold(call, io2) {
8814
8875
  const files = writtenFilesOf(template, options.names, options.fields);
8815
8876
  const app = join10(root, APPLICATION_FOLDER);
8816
8877
  const stage = join10(root, STAGE_FOLDER);
8817
- const takeLinesFor = (at) => takes.map((take) => machineLineOf(libraryTakeLineOf({ origin: at, entry: take.entry }), { windows: io2.windows ?? LINES_IN_WINDOWS_FORM, npx: ranThroughNpx(io2) }, at));
8878
+ const takeLineFor = (entry, at) => machineLineOf(libraryTakeLineOf({ origin: at, entry }), { windows: io2.windows ?? LINES_IN_WINDOWS_FORM, npx: ranThroughNpx(io2) }, at);
8879
+ const takeLinesFor = (at) => takes.map((take) => takeLineFor(take.entry, at));
8818
8880
  let lineOrigin = origin;
8881
+ const lineOf = (entry) => takeLineFor(entry, lineOrigin);
8819
8882
  let takeLines = takeLinesFor(lineOrigin);
8820
8883
  let finishWords = FINISH_WORDS;
8821
8884
  let reached = "checks";
@@ -8835,7 +8898,7 @@ async function scaffold(call, io2) {
8835
8898
  };
8836
8899
  let release = () => void 0;
8837
8900
  try {
8838
- const refused = folderRefusalOf(io2, options, files, takeLines);
8901
+ const refused = folderRefusalOf(io2, options, files, takeLines, lineOf);
8839
8902
  if (refused !== null) return refuse(...refused);
8840
8903
  const checks = [];
8841
8904
  let held;
@@ -8878,7 +8941,7 @@ async function scaffold(call, io2) {
8878
8941
  held = { library: checks[0].library, fresh: checks[0].fresh, packages: takenPackagesOf(checks) };
8879
8942
  }
8880
8943
  }
8881
- const arrived = folderRefusalOf(io2, options, files, takeLines);
8944
+ const arrived = folderRefusalOf(io2, options, files, takeLines, lineOf);
8882
8945
  if (arrived !== null) return refuse(...arrived);
8883
8946
  const toolsStands = standsAt(io2, root, TOOLS_FILE);
8884
8947
  const claudeStands = standsAt(io2, root, CLAUDE_FILE);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "turnzero",
3
- "version": "0.25.0",
3
+ "version": "0.25.1-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",