runcloud 0.1.124 → 0.1.125
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/dist/commands/create.js +9 -0
- package/dist/commands/init.js +31 -0
- package/dist/config.js +3 -0
- package/dist/index.js +2 -0
- package/dist/version.js +1 -1
- package/package.json +1 -1
- package/runcloud-0.1.125.tgz +0 -0
- package/runcloud-0.1.124.tgz +0 -0
package/dist/commands/create.js
CHANGED
|
@@ -3,7 +3,15 @@ import { join } from 'node:path';
|
|
|
3
3
|
import { ApiClient, ApiError, friendlyApiError } from '../api.js';
|
|
4
4
|
import { requireCredentials, writeProjectLink } from '../config.js';
|
|
5
5
|
import { extractSnapshot } from '../archive.js';
|
|
6
|
+
function assertNotManagedSession() {
|
|
7
|
+
const managedSessionProjectId = process.env['NEWLY_PROJECT_ID'];
|
|
8
|
+
if (!managedSessionProjectId)
|
|
9
|
+
return;
|
|
10
|
+
throw new Error(`This managed Newly session is already attached to project ${managedSessionProjectId}. ` +
|
|
11
|
+
'`newly create` would create a separate project; use `newly deploy`, `newly status`, or another project command instead.');
|
|
12
|
+
}
|
|
6
13
|
export async function runCreate(client, dir, opts) {
|
|
14
|
+
assertNotManagedSession();
|
|
7
15
|
if (existsSync(join(dir, 'backend'))) {
|
|
8
16
|
throw new Error('A `backend/` directory already exists here. Run `newly create` in a directory without one.');
|
|
9
17
|
}
|
|
@@ -42,6 +50,7 @@ export function registerCreate(program) {
|
|
|
42
50
|
.option('--no-provision', 'create without provisioning the backend')
|
|
43
51
|
.action(async (name, opts) => {
|
|
44
52
|
try {
|
|
53
|
+
assertNotManagedSession();
|
|
45
54
|
if (existsSync(join(process.cwd(), '.newly', 'project.json'))) {
|
|
46
55
|
throw new Error('This directory is already linked to a project. Use a fresh directory for `newly create`.');
|
|
47
56
|
}
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import { existsSync } from 'node:fs';
|
|
2
|
+
import { join } from 'node:path';
|
|
3
|
+
import { ApiClient, friendlyApiError } from '../api.js';
|
|
4
|
+
import { extractSnapshot } from '../archive.js';
|
|
5
|
+
import { requireCredentials, resolveProject } from '../config.js';
|
|
6
|
+
export async function runInit(client, dir, projectId) {
|
|
7
|
+
if (existsSync(join(dir, 'backend'))) {
|
|
8
|
+
throw new Error('A `backend/` directory already exists here. Use `newly deploy --env dev` to deploy it.');
|
|
9
|
+
}
|
|
10
|
+
const template = await client.getBinary('/newly_backend/backend_template');
|
|
11
|
+
await extractSnapshot(template, dir);
|
|
12
|
+
console.log(`Initialized Newly Backend for project ${projectId}. ` +
|
|
13
|
+
'Run `newly deploy --env dev` to provision the project database and deploy the services.');
|
|
14
|
+
}
|
|
15
|
+
export function registerInit(program) {
|
|
16
|
+
program
|
|
17
|
+
.command('init')
|
|
18
|
+
.description('Initialize Newly Backend in the currently linked project')
|
|
19
|
+
.action(async () => {
|
|
20
|
+
try {
|
|
21
|
+
const dir = process.cwd();
|
|
22
|
+
const projectId = resolveProject(dir, undefined);
|
|
23
|
+
const credentials = requireCredentials();
|
|
24
|
+
await runInit(new ApiClient(credentials.apiUrl, credentials.token), dir, projectId);
|
|
25
|
+
}
|
|
26
|
+
catch (error) {
|
|
27
|
+
console.error(friendlyApiError(error));
|
|
28
|
+
process.exitCode = 1;
|
|
29
|
+
}
|
|
30
|
+
});
|
|
31
|
+
}
|
package/dist/config.js
CHANGED
|
@@ -139,6 +139,9 @@ export function readProjectLink(dir) {
|
|
|
139
139
|
export function resolveProject(dir, explicit) {
|
|
140
140
|
if (explicit)
|
|
141
141
|
return explicit;
|
|
142
|
+
const managedSessionProjectId = process.env['NEWLY_PROJECT_ID'];
|
|
143
|
+
if (managedSessionProjectId)
|
|
144
|
+
return managedSessionProjectId;
|
|
142
145
|
const link = readProjectLink(dir);
|
|
143
146
|
if (link?.projectId)
|
|
144
147
|
return link.projectId;
|
package/dist/index.js
CHANGED
|
@@ -4,6 +4,7 @@ import { registerLogin } from './commands/login.js';
|
|
|
4
4
|
import { registerStatus } from './commands/status.js';
|
|
5
5
|
import { registerLink } from './commands/link.js';
|
|
6
6
|
import { registerCreate } from './commands/create.js';
|
|
7
|
+
import { registerInit } from './commands/init.js';
|
|
7
8
|
import { registerPull } from './commands/pull.js';
|
|
8
9
|
import { registerDeploy } from './commands/deploy.js';
|
|
9
10
|
import { registerMisc } from './commands/misc.js';
|
|
@@ -29,6 +30,7 @@ registerLogin(program);
|
|
|
29
30
|
registerStatus(program);
|
|
30
31
|
registerLink(program);
|
|
31
32
|
registerCreate(program);
|
|
33
|
+
registerInit(program);
|
|
32
34
|
registerPull(program);
|
|
33
35
|
registerDeploy(program);
|
|
34
36
|
registerMisc(program);
|
package/dist/version.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export const CLI_VERSION = '0.1.
|
|
1
|
+
export const CLI_VERSION = '0.1.125';
|
package/package.json
CHANGED
|
Binary file
|
package/runcloud-0.1.124.tgz
DELETED
|
Binary file
|