@nometria-ai/nom 0.2.5 → 0.2.7
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/package.json +1 -1
- package/src/commands/deploy.js +38 -5
- package/src/commands/init.js +3 -6
package/package.json
CHANGED
package/src/commands/deploy.js
CHANGED
|
@@ -5,16 +5,36 @@
|
|
|
5
5
|
import { execSync } from 'node:child_process';
|
|
6
6
|
import { existsSync } from 'node:fs';
|
|
7
7
|
import { join } from 'node:path';
|
|
8
|
-
import { readConfig, resolveEnv, updateConfig } from '../lib/config.js';
|
|
8
|
+
import { readConfig, resolveEnv, updateConfig, configExists } from '../lib/config.js';
|
|
9
9
|
import { detectServices } from '../lib/detect.js';
|
|
10
|
-
import {
|
|
10
|
+
import { getApiKey } from '../lib/auth.js';
|
|
11
11
|
import { apiRequest, uploadFile } from '../lib/api.js';
|
|
12
12
|
import { createTarball } from '../lib/tar.js';
|
|
13
13
|
import { createSpinner } from '../lib/spinner.js';
|
|
14
14
|
import { confirm } from '../lib/prompt.js';
|
|
15
|
+
import { login } from './login.js';
|
|
16
|
+
import { init } from './init.js';
|
|
15
17
|
|
|
16
18
|
export async function deploy(flags) {
|
|
17
|
-
|
|
19
|
+
// Auto-login if not authenticated
|
|
20
|
+
let apiKey = getApiKey();
|
|
21
|
+
if (!apiKey) {
|
|
22
|
+
console.log('\n No credentials found. Signing in first...\n');
|
|
23
|
+
await login(flags);
|
|
24
|
+
apiKey = getApiKey();
|
|
25
|
+
if (!apiKey) {
|
|
26
|
+
const err = new Error('Not authenticated');
|
|
27
|
+
err.code = 'ERR_AUTH';
|
|
28
|
+
throw err;
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
// Auto-init if no nometria.json
|
|
33
|
+
if (!configExists(process.cwd())) {
|
|
34
|
+
console.log(' No nometria.json found. Setting up project...\n');
|
|
35
|
+
await init({ yes: true });
|
|
36
|
+
}
|
|
37
|
+
|
|
18
38
|
const config = readConfig();
|
|
19
39
|
const envVars = resolveEnv(config.env);
|
|
20
40
|
const appName = config.name || config.app_id;
|
|
@@ -100,7 +120,13 @@ export async function deploy(flags) {
|
|
|
100
120
|
|
|
101
121
|
// Step 5: Poll for status via Deno function
|
|
102
122
|
const deployId = deployResult.deploy_id || appName;
|
|
123
|
+
const dashboardUrl = `https://nometria.com/AppDetails?app_id=${deployId}`;
|
|
124
|
+
console.log(`\n Dashboard: ${dashboardUrl}`);
|
|
125
|
+
console.log(` You can close this terminal — check the dashboard for progress.\n`);
|
|
126
|
+
|
|
103
127
|
let finalStatus;
|
|
128
|
+
const pollStart = Date.now();
|
|
129
|
+
const POLL_TIMEOUT_MS = 10 * 60 * 1000; // 10 minutes
|
|
104
130
|
while (true) {
|
|
105
131
|
await sleep(3000);
|
|
106
132
|
try {
|
|
@@ -128,6 +154,13 @@ export async function deploy(flags) {
|
|
|
128
154
|
deploySpinner.fail(`${isResync ? 'Resync' : 'Deploy'} failed: ${statusResult.data?.errorMessage || 'unknown error'}`);
|
|
129
155
|
process.exit(1);
|
|
130
156
|
}
|
|
157
|
+
|
|
158
|
+
// Timeout: if instance is running but status stuck at deploying, show URL and exit
|
|
159
|
+
if (Date.now() - pollStart > POLL_TIMEOUT_MS && instanceState === 'running') {
|
|
160
|
+
finalStatus = statusResult;
|
|
161
|
+
deploySpinner.succeed('Deploy in progress — check dashboard for final status');
|
|
162
|
+
break;
|
|
163
|
+
}
|
|
131
164
|
} catch {
|
|
132
165
|
// Keep polling on transient errors
|
|
133
166
|
}
|
|
@@ -142,10 +175,10 @@ export async function deploy(flags) {
|
|
|
142
175
|
}
|
|
143
176
|
|
|
144
177
|
// Step 7: Print result
|
|
145
|
-
const url = finalStatus.data?.deployUrl || finalStatus.url || `https://${
|
|
178
|
+
const url = finalStatus.data?.deployUrl || finalStatus.url || `https://${deployId}.ownmy.app`;
|
|
146
179
|
console.log(`
|
|
147
180
|
Live at: ${url}
|
|
148
|
-
Dashboard: https://nometria.com/AppDetails?app_id=${
|
|
181
|
+
Dashboard: https://nometria.com/AppDetails?app_id=${deployId}
|
|
149
182
|
`);
|
|
150
183
|
|
|
151
184
|
// Step 8: Auto-detect git repo and offer GitHub connection
|
package/src/commands/init.js
CHANGED
|
@@ -88,13 +88,10 @@ export async function init(flags) {
|
|
|
88
88
|
const configPath = join(dir, CONFIG_FILE);
|
|
89
89
|
writeFileSync(configPath, JSON.stringify(config, null, 2) + '\n');
|
|
90
90
|
|
|
91
|
-
console.log(`\n Created ${CONFIG_FILE}`);
|
|
92
|
-
|
|
93
|
-
// Auto-generate AI tool configs
|
|
94
|
-
const { setup } = await import('./setup.js');
|
|
95
|
-
await setup({ yes: true });
|
|
91
|
+
console.log(`\n Created ${CONFIG_FILE}\n`);
|
|
96
92
|
|
|
97
93
|
console.log(` Next steps:`);
|
|
98
94
|
console.log(` 1. Run nom login to authenticate`);
|
|
99
|
-
console.log(` 2. Run nom deploy to deploy
|
|
95
|
+
console.log(` 2. Run nom deploy to deploy`);
|
|
96
|
+
console.log(` 3. Run nom setup to generate AI tool configs (optional)\n`);
|
|
100
97
|
}
|