@newly/cli 0.1.96 → 0.1.98
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/README.md +17 -0
- package/dist/commands/update.js +66 -0
- package/dist/diagnose.js +4 -4
- package/dist/index.js +2 -0
- package/dist/version.js +1 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -10,6 +10,18 @@ npm i -g @newly/cli
|
|
|
10
10
|
|
|
11
11
|
Installs the `newly` binary. Requires **Node ≥ 20**.
|
|
12
12
|
|
|
13
|
+
### Updating
|
|
14
|
+
|
|
15
|
+
```bash
|
|
16
|
+
newly --update # or: newly -u
|
|
17
|
+
newly --version # confirm what you are on
|
|
18
|
+
```
|
|
19
|
+
|
|
20
|
+
`--update` checks the registry and installs the latest release, or tells you that
|
|
21
|
+
you are already on it. If the global install needs elevated permissions it prints
|
|
22
|
+
the underlying error and the command to run by hand
|
|
23
|
+
(`npm install -g @newly/cli@latest`).
|
|
24
|
+
|
|
13
25
|
## Quick start
|
|
14
26
|
|
|
15
27
|
```bash
|
|
@@ -89,6 +101,11 @@ Service names are positional. With no names, every service in
|
|
|
89
101
|
|
|
90
102
|
## Commands
|
|
91
103
|
|
|
104
|
+
### `newly --update` / `newly -u`
|
|
105
|
+
Update the CLI to the latest published version. Reports the version it moved to,
|
|
106
|
+
or says you are already current without reinstalling. On failure it prints npm's
|
|
107
|
+
own error alongside `npm install -g @newly/cli@latest` so the fix is a copy/paste.
|
|
108
|
+
|
|
92
109
|
### `newly pull [project-id]`
|
|
93
110
|
Download the project working tree (app + backend) into the current directory and link it.
|
|
94
111
|
- `--branch <name>` — pull a specific branch (default: project's active branch).
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
import { execFile } from 'node:child_process';
|
|
2
|
+
import { promisify } from 'node:util';
|
|
3
|
+
import { CLI_VERSION } from '../version.js';
|
|
4
|
+
export const PACKAGE_NAME = '@newly/cli';
|
|
5
|
+
export const UPDATE_COMMAND = `npm install -g ${PACKAGE_NAME}@latest`;
|
|
6
|
+
const defaultExec = async (file, args) => {
|
|
7
|
+
const { stdout } = await promisify(execFile)(file, args, { encoding: 'utf8' });
|
|
8
|
+
return { stdout };
|
|
9
|
+
};
|
|
10
|
+
function errorText(error) {
|
|
11
|
+
if (error && typeof error === 'object') {
|
|
12
|
+
const stderr = error.stderr;
|
|
13
|
+
if (typeof stderr === 'string' && stderr.trim())
|
|
14
|
+
return stderr.trim();
|
|
15
|
+
}
|
|
16
|
+
return error instanceof Error ? error.message : String(error);
|
|
17
|
+
}
|
|
18
|
+
export async function latestPublishedVersion(exec) {
|
|
19
|
+
const { stdout } = await exec('npm', ['view', `${PACKAGE_NAME}@latest`, 'version']);
|
|
20
|
+
return stdout.trim();
|
|
21
|
+
}
|
|
22
|
+
export async function updateCli(deps = {}) {
|
|
23
|
+
const exec = deps.exec ?? defaultExec;
|
|
24
|
+
const log = deps.log ?? ((message) => console.log(message));
|
|
25
|
+
const current = deps.currentVersion ?? CLI_VERSION;
|
|
26
|
+
let latest;
|
|
27
|
+
try {
|
|
28
|
+
latest = await latestPublishedVersion(exec);
|
|
29
|
+
}
|
|
30
|
+
catch (error) {
|
|
31
|
+
throw new Error(`Could not reach the npm registry to check for updates: ${errorText(error)}\n` +
|
|
32
|
+
`Run \`${UPDATE_COMMAND}\` to update by hand.`);
|
|
33
|
+
}
|
|
34
|
+
if (!latest) {
|
|
35
|
+
throw new Error(`The npm registry did not report a version for ${PACKAGE_NAME}.\n` +
|
|
36
|
+
`Run \`${UPDATE_COMMAND}\` to update by hand.`);
|
|
37
|
+
}
|
|
38
|
+
if (latest === current) {
|
|
39
|
+
log(`Already on the latest version (${current}).`);
|
|
40
|
+
return;
|
|
41
|
+
}
|
|
42
|
+
log(`Updating ${PACKAGE_NAME} ${current} → ${latest}…`);
|
|
43
|
+
try {
|
|
44
|
+
await exec('npm', ['install', '-g', `${PACKAGE_NAME}@latest`]);
|
|
45
|
+
}
|
|
46
|
+
catch (error) {
|
|
47
|
+
throw new Error(`Update failed: ${errorText(error)}\n` + `Run \`${UPDATE_COMMAND}\` to update by hand.`);
|
|
48
|
+
}
|
|
49
|
+
log(`Updated to ${latest}.`);
|
|
50
|
+
}
|
|
51
|
+
export function registerUpdate(program) {
|
|
52
|
+
program.option('-u, --update', 'update this CLI to the latest published version');
|
|
53
|
+
program.action(async () => {
|
|
54
|
+
if (program.opts().update !== true) {
|
|
55
|
+
program.help();
|
|
56
|
+
return;
|
|
57
|
+
}
|
|
58
|
+
try {
|
|
59
|
+
await updateCli();
|
|
60
|
+
}
|
|
61
|
+
catch (error) {
|
|
62
|
+
console.error(error instanceof Error ? error.message : String(error));
|
|
63
|
+
process.exitCode = 1;
|
|
64
|
+
}
|
|
65
|
+
});
|
|
66
|
+
}
|
package/dist/diagnose.js
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
const DEFAULT_URLS = {
|
|
2
2
|
dev: {
|
|
3
|
-
apiOps: 'https://cp-api-ops-dev.
|
|
4
|
-
worker: 'https://cp-worker-dev.
|
|
3
|
+
apiOps: 'https://cp-api-ops-dev-97683904813.us-east4.run.app',
|
|
4
|
+
worker: 'https://cp-worker-dev-97683904813.us-east4.run.app',
|
|
5
5
|
},
|
|
6
6
|
prod: {
|
|
7
|
-
apiOps: 'https://cp-api-ops-prod.
|
|
8
|
-
worker: 'https://cp-worker-prod.
|
|
7
|
+
apiOps: 'https://cp-api-ops-prod-350096142301.us-east4.run.app',
|
|
8
|
+
worker: 'https://cp-worker-prod-350096142301.us-east4.run.app',
|
|
9
9
|
},
|
|
10
10
|
};
|
|
11
11
|
function stripSlash(url) {
|
package/dist/index.js
CHANGED
|
@@ -19,6 +19,7 @@ import { registerDiagnose } from './diagnose.js';
|
|
|
19
19
|
import { registerDesktop } from './commands/desktop.js';
|
|
20
20
|
import { registerEnvironment } from './commands/environment.js';
|
|
21
21
|
import { registerAppStore } from './commands/appStore.js';
|
|
22
|
+
import { registerUpdate } from './commands/update.js';
|
|
22
23
|
import { CLI_VERSION } from './version.js';
|
|
23
24
|
const program = new Command('newly')
|
|
24
25
|
.description('Develop, provision, and deploy Newly backends')
|
|
@@ -42,4 +43,5 @@ registerDiagnose(program);
|
|
|
42
43
|
registerDesktop(program);
|
|
43
44
|
registerEnvironment(program);
|
|
44
45
|
registerAppStore(program);
|
|
46
|
+
registerUpdate(program);
|
|
45
47
|
await program.parseAsync(process.argv);
|
package/dist/version.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export const CLI_VERSION = '0.1.
|
|
1
|
+
export const CLI_VERSION = '0.1.98';
|