@nometria-ai/nom 0.1.0
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/LICENSE +21 -0
- package/README.md +112 -0
- package/package.json +47 -0
- package/src/cli.js +164 -0
- package/src/commands/deploy.js +157 -0
- package/src/commands/domain.js +57 -0
- package/src/commands/env.js +120 -0
- package/src/commands/github.js +291 -0
- package/src/commands/init.js +90 -0
- package/src/commands/login.js +280 -0
- package/src/commands/logs.js +49 -0
- package/src/commands/preview.js +60 -0
- package/src/commands/scan.js +70 -0
- package/src/commands/setup.js +854 -0
- package/src/commands/start.js +26 -0
- package/src/commands/status.js +33 -0
- package/src/commands/stop.js +24 -0
- package/src/commands/terminate.js +33 -0
- package/src/commands/upgrade.js +49 -0
- package/src/commands/whoami.js +18 -0
- package/src/lib/api.js +85 -0
- package/src/lib/auth.js +56 -0
- package/src/lib/config.js +93 -0
- package/src/lib/detect.js +88 -0
- package/src/lib/prompt.js +76 -0
- package/src/lib/spinner.js +43 -0
- package/src/lib/tar.js +55 -0
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* nom preview — Deploy a staging preview via Deno functions.
|
|
3
|
+
*/
|
|
4
|
+
import { execSync } from 'node:child_process';
|
|
5
|
+
import { readConfig, resolveEnv } from '../lib/config.js';
|
|
6
|
+
import { requireApiKey } from '../lib/auth.js';
|
|
7
|
+
import { apiRequest, uploadFile } from '../lib/api.js';
|
|
8
|
+
import { createTarball } from '../lib/tar.js';
|
|
9
|
+
import { createSpinner } from '../lib/spinner.js';
|
|
10
|
+
|
|
11
|
+
export async function preview(flags) {
|
|
12
|
+
const apiKey = requireApiKey();
|
|
13
|
+
const config = readConfig();
|
|
14
|
+
const appName = config.name || config.app_id;
|
|
15
|
+
|
|
16
|
+
console.log(`\n Creating preview for ${appName}\n`);
|
|
17
|
+
|
|
18
|
+
// Build
|
|
19
|
+
if (config.build?.command) {
|
|
20
|
+
const spinner = createSpinner('Building').start();
|
|
21
|
+
try {
|
|
22
|
+
execSync(config.build.command, {
|
|
23
|
+
cwd: process.cwd(),
|
|
24
|
+
stdio: 'pipe',
|
|
25
|
+
env: { ...process.env, NODE_ENV: 'production' },
|
|
26
|
+
});
|
|
27
|
+
spinner.succeed('Built successfully');
|
|
28
|
+
} catch (err) {
|
|
29
|
+
spinner.fail('Build failed');
|
|
30
|
+
console.error(`\n${err.stderr?.toString() || err.message}\n`);
|
|
31
|
+
process.exit(1);
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
// Archive
|
|
36
|
+
const archiveSpinner = createSpinner('Creating archive').start();
|
|
37
|
+
const tarball = createTarball(process.cwd(), config.ignore);
|
|
38
|
+
archiveSpinner.succeed(`Archive created (${tarball.sizeFormatted})`);
|
|
39
|
+
|
|
40
|
+
// Upload via Deno function
|
|
41
|
+
const uploadSpinner = createSpinner('Uploading').start();
|
|
42
|
+
const uploadResult = await uploadFile(apiKey, tarball.buffer, `${appName}-preview.tar.gz`);
|
|
43
|
+
uploadSpinner.succeed(`Uploaded (${tarball.sizeFormatted})`);
|
|
44
|
+
|
|
45
|
+
// Deploy preview via Deno function
|
|
46
|
+
const deploySpinner = createSpinner('Creating preview').start();
|
|
47
|
+
const result = await apiRequest('/cli/preview', {
|
|
48
|
+
apiKey,
|
|
49
|
+
body: {
|
|
50
|
+
app_name: appName,
|
|
51
|
+
upload_url: uploadResult.upload_url,
|
|
52
|
+
},
|
|
53
|
+
});
|
|
54
|
+
deploySpinner.succeed('Preview ready');
|
|
55
|
+
|
|
56
|
+
console.log(`
|
|
57
|
+
Preview: ${result.preview_url}
|
|
58
|
+
Expires in: ${result.expires_in || '2 hours'}
|
|
59
|
+
`);
|
|
60
|
+
}
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* nom scan — Run a deployment scan/audit via Deno functions.
|
|
3
|
+
*/
|
|
4
|
+
import { readConfig } from '../lib/config.js';
|
|
5
|
+
import { requireApiKey } from '../lib/auth.js';
|
|
6
|
+
import { apiRequest } from '../lib/api.js';
|
|
7
|
+
|
|
8
|
+
export async function scan(flags) {
|
|
9
|
+
const apiKey = requireApiKey();
|
|
10
|
+
const config = readConfig();
|
|
11
|
+
const appId = config.app_id || config.name;
|
|
12
|
+
|
|
13
|
+
console.log(`\n Scanning ${appId}...\n`);
|
|
14
|
+
|
|
15
|
+
const result = await apiRequest('/runAiScan', {
|
|
16
|
+
apiKey,
|
|
17
|
+
body: { app_id: appId, migration_id: config.migration_id },
|
|
18
|
+
});
|
|
19
|
+
|
|
20
|
+
if (flags.json) {
|
|
21
|
+
console.log(JSON.stringify(result, null, 2));
|
|
22
|
+
return;
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
// Backend may nest under result.results
|
|
26
|
+
const data = result.results || result;
|
|
27
|
+
|
|
28
|
+
// Display scores
|
|
29
|
+
const scoreKeys = ['securityScore', 'performanceScore', 'codeQuality'];
|
|
30
|
+
const hasScores = scoreKeys.some(k => data[k] != null);
|
|
31
|
+
if (hasScores) {
|
|
32
|
+
console.log(' Scores:');
|
|
33
|
+
for (const key of scoreKeys) {
|
|
34
|
+
if (data[key] != null) {
|
|
35
|
+
const label = key.replace(/([A-Z])/g, ' $1').trim();
|
|
36
|
+
const bar = buildBar(data[key]);
|
|
37
|
+
console.log(` ${label.padEnd(20)} ${bar} ${data[key]}/100`);
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
console.log();
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
// Display overall score
|
|
44
|
+
const overall = data.overall_score || result.overall_score;
|
|
45
|
+
if (overall != null) {
|
|
46
|
+
console.log(` Overall: ${overall}/100\n`);
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
// Display issues
|
|
50
|
+
const issues = data.issues || result.issues || [];
|
|
51
|
+
if (issues.length) {
|
|
52
|
+
console.log(' Issues:\n');
|
|
53
|
+
for (const issue of issues) {
|
|
54
|
+
const severity = (issue.severity || 'info').toUpperCase().padEnd(8);
|
|
55
|
+
const msg = issue.message || issue.title || 'Unknown issue';
|
|
56
|
+
console.log(` [${severity}] ${msg}`);
|
|
57
|
+
if (issue.description) console.log(` ${issue.description}`);
|
|
58
|
+
if (issue.fix) console.log(` Fix: ${issue.fix}`);
|
|
59
|
+
}
|
|
60
|
+
console.log();
|
|
61
|
+
} else {
|
|
62
|
+
console.log(' No issues found.\n');
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
function buildBar(score, width = 20) {
|
|
67
|
+
const filled = Math.round((score / 100) * width);
|
|
68
|
+
const empty = width - filled;
|
|
69
|
+
return '[' + '#'.repeat(filled) + '-'.repeat(empty) + ']';
|
|
70
|
+
}
|