@next-generation-collective/factory 0.3.0 → 0.3.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.
Files changed (2) hide show
  1. package/lib/cli.js +25 -0
  2. package/package.json +1 -1
package/lib/cli.js CHANGED
@@ -1,3 +1,5 @@
1
+ import { homedir } from "node:os";
2
+ import { parse as parse_, resolve } from "node:path";
1
3
  import { createRequire } from "node:module";
2
4
  import {
3
5
  approveCommand,
@@ -95,6 +97,20 @@ Nothing is written into your project until you start a job. Nothing is called
95
97
  done until the checks pass, and it never says "bug-free" or "compliant".`);
96
98
  }
97
99
 
100
+ // Your home folder or the top of the disk is never one project. Reading it means reading
101
+ // every file on the computer, which takes minutes and shows nothing.
102
+ export function notAProjectFolder(root, home = homedir()) {
103
+ const here = resolve(root);
104
+ if (here !== resolve(home) && here !== parse_(here).root) return null;
105
+ return [
106
+ `This is ${here === resolve(home) ? "your home folder" : "the top of your disk"}, not a project.`,
107
+ "Go into a project folder first, then run it again. For example:",
108
+ "",
109
+ " cd my-project",
110
+ " npx @next-generation-collective/factory",
111
+ ].join("\n");
112
+ }
113
+
98
114
  export async function main(argv) {
99
115
  const { flags, positional } = parse(argv);
100
116
  const root = process.cwd();
@@ -110,6 +126,15 @@ export async function main(argv) {
110
126
  return 0;
111
127
  }
112
128
 
129
+ if (!command || (!COMMANDS.has(command) && (rest.length > 0 || /\s/.test(command)))) {
130
+ const refusal = notAProjectFolder(root);
131
+ if (refusal) {
132
+ console.error(refusal);
133
+ return 1;
134
+ }
135
+ if (process.stderr.isTTY) process.stderr.write("Reading your project...\n\n");
136
+ }
137
+
113
138
  if (!command) return start(root, flags);
114
139
 
115
140
  if (!COMMANDS.has(command)) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@next-generation-collective/factory",
3
- "version": "0.3.0",
3
+ "version": "0.3.1",
4
4
  "description": "Checks the work you build with AI, proves it works, and learns from every builder. Built in the open, in Africa.",
5
5
  "type": "module",
6
6
  "bin": {