@redue/cli 0.1.0-alpha.25 → 0.1.0-alpha.26

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/src/setup.mjs CHANGED
@@ -38,7 +38,8 @@ export async function setupCommand(args,{entry,cwd=process.cwd()}){
38
38
  const top=git(cwd,'rev-parse','--show-toplevel');
39
39
  if(top.status!==0)throw Error('run this inside a Git checkout');
40
40
  const root=fs.realpathSync(top.stdout.trim());
41
- if(!fs.existsSync(path.join(root,'package.json')))throw Error(`no package.json at the repository root (${root})`);
41
+ if(!['package.json','pyproject.toml','setup.cfg','setup.py','requirements.txt'].some(file=>fs.existsSync(path.join(root,file))))
42
+ throw Error(`no package.json or Python project at the repository root (${root})`);
42
43
  // The entry as invoked, so a hook written by a child names the install's
43
44
  // stable bin link rather than the versioned file behind it.
44
45
  const invoked=typeof process.argv[1]==='string'&&path.isAbsolute(process.argv[1])&&
@@ -59,8 +60,12 @@ export async function setupCommand(args,{entry,cwd=process.cwd()}){
59
60
  }
60
61
 
61
62
  async function setup({root,redue,yes,record:previous,recordFile,exclude,save}){
62
- if(!fs.existsSync(path.join(root,'node_modules')))
63
+ // A Node project needs node_modules; a Python one its .venv.
64
+ const node=fs.existsSync(path.join(root,'package.json'));
65
+ if(node&&!fs.existsSync(path.join(root,'node_modules')))
63
66
  throw Error('dependencies are not installed: run your package manager\'s install (npm install, pnpm install, yarn) first');
67
+ if(!node&&!fs.existsSync(path.join(root,'.venv','pyvenv.cfg')))
68
+ throw Error('no .venv in the project root: create it first (uv sync, or Poetry with virtualenvs.in-project)');
64
69
  if(fs.existsSync(path.join(root,'vstate.config.json'))&&!fs.existsSync(path.join(root,configName)))
65
70
  throw Error('a legacy vstate.config.json exists; rename it to redue.config.json or remove it first');
66
71
  if(git(root,'ls-files','--error-unmatch',localSettings).status===0)