gitarsenal-cli 1.0.0 → 1.0.2

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/bin/gitarsenal.js CHANGED
@@ -29,8 +29,9 @@ program
29
29
  .description('Create Modal sandboxes with GitHub repositories')
30
30
  .option('-r, --repo <url>', 'GitHub repository URL')
31
31
  .option('-g, --gpu <type>', 'GPU type (A10G, A100, H100, T4, V100)', 'A10G')
32
- .option('-v, --volume <name>', 'Name of persistent volume')
32
+ .option('-v, --volume <n>', 'Name of persistent volume')
33
33
  .option('-y, --yes', 'Skip confirmation prompts')
34
+ .option('-m, --manual', 'Disable automatic setup command detection')
34
35
  .parse(process.argv);
35
36
 
36
37
  const options = program.opts();
@@ -52,6 +53,7 @@ async function main() {
52
53
  let gpuType = options.gpu;
53
54
  let volumeName = options.volume;
54
55
  let skipConfirmation = options.yes;
56
+ let useApi = !options.manual;
55
57
 
56
58
  if (!repoUrl) {
57
59
  const answers = await inquirer.prompt([
@@ -108,32 +110,49 @@ async function main() {
108
110
  }
109
111
  }
110
112
 
111
- // Prompt for custom setup commands
112
- const setupAnswers = await inquirer.prompt([
113
- {
114
- type: 'confirm',
115
- name: 'useCustomCommands',
116
- message: 'Provide custom setup commands?',
117
- default: false
118
- }
119
- ]);
113
+ // Ask about setup command detection if not specified via CLI
114
+ if (!options.manual && !options.yes) {
115
+ const apiAnswers = await inquirer.prompt([
116
+ {
117
+ type: 'confirm',
118
+ name: 'useApi',
119
+ message: 'Automatically detect setup commands for this repository?',
120
+ default: true
121
+ }
122
+ ]);
123
+
124
+ useApi = apiAnswers.useApi;
125
+ }
120
126
 
121
127
  let setupCommands = [];
122
- if (setupAnswers.useCustomCommands) {
123
- console.log(chalk.yellow('Enter setup commands (one per line). Type "done" on a new line when finished:'));
124
-
125
- const commandsInput = await inquirer.prompt([
128
+
129
+ // Only prompt for custom commands if auto-detection is disabled
130
+ if (!useApi) {
131
+ const setupAnswers = await inquirer.prompt([
126
132
  {
127
- type: 'editor',
128
- name: 'commands',
129
- message: 'Enter setup commands:',
130
- default: '# Enter one command per line\n# Example: pip install -r requirements.txt\n'
133
+ type: 'confirm',
134
+ name: 'useCustomCommands',
135
+ message: 'Provide custom setup commands?',
136
+ default: true
131
137
  }
132
138
  ]);
133
-
134
- setupCommands = commandsInput.commands
135
- .split('\n')
136
- .filter(line => line.trim() !== '' && !line.trim().startsWith('#'));
139
+
140
+ if (setupAnswers.useCustomCommands) {
141
+ console.log(chalk.yellow('Enter setup commands (one per line). Type "done" on a new line when finished:'));
142
+
143
+ const commandsInput = await inquirer.prompt([
144
+ {
145
+ type: 'editor',
146
+ name: 'commands',
147
+ message: 'Enter setup commands:',
148
+ default: '# Enter one command per line\n# Example: pip install -r requirements.txt\n'
149
+ }
150
+ ]);
151
+
152
+ setupCommands = commandsInput.commands
153
+ .split('\n')
154
+ .filter(line => line.trim() !== '' && !line.trim().startsWith('#'));
155
+ }
137
156
  }
138
157
 
139
158
  // Show configuration summary
@@ -142,13 +161,15 @@ async function main() {
142
161
  console.log(chalk.cyan('GPU Type: ') + gpuType);
143
162
  console.log(chalk.cyan('Volume: ') + (volumeName || 'None'));
144
163
 
145
- if (setupCommands.length > 0) {
164
+ if (useApi) {
165
+ console.log(chalk.cyan('Setup Commands: ') + 'Auto-detect from repository');
166
+ } else if (setupCommands.length > 0) {
146
167
  console.log(chalk.cyan('Setup Commands:'));
147
168
  setupCommands.forEach((cmd, i) => {
148
169
  console.log(` ${i + 1}. ${cmd}`);
149
170
  });
150
171
  } else {
151
- console.log(chalk.cyan('Setup Commands: ') + 'None (will use defaults)');
172
+ console.log(chalk.cyan('Setup Commands: ') + 'None');
152
173
  }
153
174
 
154
175
  // Confirm settings
@@ -173,7 +194,8 @@ async function main() {
173
194
  repoUrl,
174
195
  gpuType,
175
196
  volumeName,
176
- setupCommands
197
+ setupCommands,
198
+ useApi
177
199
  });
178
200
 
179
201
  } catch (error) {
package/lib/sandbox.js CHANGED
@@ -32,10 +32,11 @@ function getPythonScriptPath() {
32
32
  * @param {string} options.gpuType - GPU type
33
33
  * @param {string} options.volumeName - Volume name
34
34
  * @param {Array<string>} options.setupCommands - Setup commands
35
+ * @param {boolean} options.useApi - Whether to use the API to fetch setup commands
35
36
  * @returns {Promise<void>}
36
37
  */
37
38
  async function runModalSandbox(options) {
38
- const { repoUrl, gpuType, volumeName, setupCommands = [] } = options;
39
+ const { repoUrl, gpuType, volumeName, setupCommands = [], useApi = true } = options;
39
40
 
40
41
  // Get the path to the Python script
41
42
  const scriptPath = getPythonScriptPath();
@@ -56,7 +57,12 @@ async function runModalSandbox(options) {
56
57
  args.push('--volume-name', volumeName);
57
58
  }
58
59
 
59
- // Handle setup commands
60
+ // Always use the API to fetch setup commands unless explicitly disabled
61
+ if (useApi) {
62
+ args.push('--use-api');
63
+ }
64
+
65
+ // Handle manual setup commands if provided
60
66
  if (setupCommands.length > 0) {
61
67
  // Create a temporary file to store setup commands
62
68
  const tempCommandsFile = path.join(os.tmpdir(), `gitarsenal-commands-${Date.now()}.txt`);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "gitarsenal-cli",
3
- "version": "1.0.0",
3
+ "version": "1.0.2",
4
4
  "description": "CLI tool for creating Modal sandboxes with GitHub repositories",
5
5
  "main": "index.js",
6
6
  "bin": {