doomain 0.1.20 → 0.1.21
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/update.d.ts +9 -0
- package/dist/commands/update.js +28 -0
- package/dist/commands/upgrade.d.ts +1 -0
- package/dist/commands/upgrade.js +1 -0
- package/dist/lib/command-schema.js +14 -0
- package/dist/lib/errors.d.ts +1 -1
- package/dist/lib/self-update.d.ts +27 -0
- package/dist/lib/self-update.js +63 -0
- package/oclif.manifest.json +63 -1
- package/package.json +1 -1
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import { Command } from '@oclif/core';
|
|
2
|
+
import { jsonFlag } from '../lib/flags.js';
|
|
3
|
+
import { createOutput, outputError } from '../lib/output.js';
|
|
4
|
+
import { installLatestVersion } from '../lib/self-update.js';
|
|
5
|
+
export default class Update extends Command {
|
|
6
|
+
static description = 'Install the latest doomain version from npm without using the existing npm cache.';
|
|
7
|
+
static examples = ['<%= config.bin %> <%= command.id %>', '<%= config.bin %> <%= command.id %> --json'];
|
|
8
|
+
static flags = {
|
|
9
|
+
json: jsonFlag,
|
|
10
|
+
};
|
|
11
|
+
async run() {
|
|
12
|
+
const { flags } = await this.parse(Update);
|
|
13
|
+
const out = createOutput({ json: flags.json });
|
|
14
|
+
const spinner = out.spinner();
|
|
15
|
+
try {
|
|
16
|
+
spinner.start('Downloading the latest doomain version from npm');
|
|
17
|
+
const result = await installLatestVersion();
|
|
18
|
+
spinner.stop('Installed the latest doomain version');
|
|
19
|
+
out.result(result);
|
|
20
|
+
out.success('Installed the latest doomain version from npm.');
|
|
21
|
+
}
|
|
22
|
+
catch (error) {
|
|
23
|
+
spinner.error('Update failed');
|
|
24
|
+
outputError(out.json, error, 'SELF_UPDATE_FAILED');
|
|
25
|
+
this.exit(1);
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { default } from './update.js';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { default } from './update.js';
|
|
@@ -164,6 +164,20 @@ export const commandSchemas = [
|
|
|
164
164
|
safeForAgents: true,
|
|
165
165
|
flags: [{ name: 'json', type: 'boolean', description: 'Output a single JSON object and never prompt.' }],
|
|
166
166
|
},
|
|
167
|
+
{
|
|
168
|
+
name: 'update',
|
|
169
|
+
description: 'Install the latest doomain version from npm without using the existing npm cache.',
|
|
170
|
+
examples: ['doomain update', 'doomain update --json'],
|
|
171
|
+
mutates: true,
|
|
172
|
+
flags: [{ name: 'json', type: 'boolean', description: 'Output a single JSON object and never prompt.' }],
|
|
173
|
+
},
|
|
174
|
+
{
|
|
175
|
+
name: 'upgrade',
|
|
176
|
+
description: 'Alias for update.',
|
|
177
|
+
examples: ['doomain upgrade', 'doomain upgrade --json'],
|
|
178
|
+
mutates: true,
|
|
179
|
+
flags: [{ name: 'json', type: 'boolean', description: 'Output a single JSON object and never prompt.' }],
|
|
180
|
+
},
|
|
167
181
|
{
|
|
168
182
|
name: 'providers list',
|
|
169
183
|
description: 'List supported DNS providers.',
|
package/dist/lib/errors.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export type DoomainErrorCode = 'CONFIG_NOT_FOUND' | 'CLERK_AUTH_FAILED' | 'CLERK_PRODUCTION_EXISTS' | 'DNS_POINT_FAILED' | 'DNS_TARGET_CONFLICT' | 'DOMAIN_LINK_FAILED' | 'DOMAIN_PROVIDER_DISCOVERY_FAILED' | 'DOMAIN_ALREADY_ASSIGNED' | 'DOMAIN_VERIFY_FAILED' | 'INVALID_INPUT' | 'MISSING_ARGUMENT' | 'MISSING_CREDENTIALS' | 'PROVIDER_API_ERROR' | 'PROVIDER_AUTH_FAILED' | 'PROVIDER_PERMISSION_DENIED' | 'PROVIDER_NOT_FOUND' | 'PROVIDER_RATE_LIMITED' | 'PROVIDER_RECORD_CONFLICT' | 'PROVIDER_UNSUPPORTED_RECORD' | 'PROVIDER_ZONE_AMBIGUOUS' | 'PROVIDER_ZONE_NOT_FOUND' | 'PROJECT_NOT_FOUND' | 'VERCEL_AUTH_FAILED' | 'VERCEL_PROJECT_NOT_LINKED';
|
|
1
|
+
export type DoomainErrorCode = 'CONFIG_NOT_FOUND' | 'CLERK_AUTH_FAILED' | 'CLERK_PRODUCTION_EXISTS' | 'DNS_POINT_FAILED' | 'DNS_TARGET_CONFLICT' | 'DOMAIN_LINK_FAILED' | 'DOMAIN_PROVIDER_DISCOVERY_FAILED' | 'DOMAIN_ALREADY_ASSIGNED' | 'DOMAIN_VERIFY_FAILED' | 'INVALID_INPUT' | 'MISSING_ARGUMENT' | 'MISSING_CREDENTIALS' | 'PROVIDER_API_ERROR' | 'PROVIDER_AUTH_FAILED' | 'PROVIDER_PERMISSION_DENIED' | 'PROVIDER_NOT_FOUND' | 'PROVIDER_RATE_LIMITED' | 'PROVIDER_RECORD_CONFLICT' | 'PROVIDER_UNSUPPORTED_RECORD' | 'PROVIDER_ZONE_AMBIGUOUS' | 'PROVIDER_ZONE_NOT_FOUND' | 'PROJECT_NOT_FOUND' | 'SELF_UPDATE_FAILED' | 'VERCEL_AUTH_FAILED' | 'VERCEL_PROJECT_NOT_LINKED';
|
|
2
2
|
export declare class DoomainError extends Error {
|
|
3
3
|
readonly code: DoomainErrorCode;
|
|
4
4
|
readonly details?: unknown;
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
interface ProcessResult {
|
|
2
|
+
exitCode: number | null;
|
|
3
|
+
stderr: string;
|
|
4
|
+
stdout: string;
|
|
5
|
+
}
|
|
6
|
+
interface ProcessOptions {
|
|
7
|
+
env: NodeJS.ProcessEnv;
|
|
8
|
+
shell: boolean;
|
|
9
|
+
}
|
|
10
|
+
type ProcessRunner = (command: string, args: string[], options: ProcessOptions) => Promise<ProcessResult>;
|
|
11
|
+
export interface SelfUpdateResult {
|
|
12
|
+
package: string;
|
|
13
|
+
packageSpec: string;
|
|
14
|
+
packageManager: 'npm';
|
|
15
|
+
}
|
|
16
|
+
export interface SelfUpdateOptions {
|
|
17
|
+
cacheRoot?: string;
|
|
18
|
+
platform?: NodeJS.Platform;
|
|
19
|
+
runner?: ProcessRunner;
|
|
20
|
+
}
|
|
21
|
+
export declare function npmInstallCommand(cacheDirectory: string, platform?: NodeJS.Platform, environment?: NodeJS.ProcessEnv): {
|
|
22
|
+
args: string[];
|
|
23
|
+
command: string;
|
|
24
|
+
options: ProcessOptions;
|
|
25
|
+
};
|
|
26
|
+
export declare function installLatestVersion(options?: SelfUpdateOptions): Promise<SelfUpdateResult>;
|
|
27
|
+
export {};
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
import { spawn } from 'node:child_process';
|
|
2
|
+
import { mkdtemp, rm } from 'node:fs/promises';
|
|
3
|
+
import { tmpdir } from 'node:os';
|
|
4
|
+
import { join } from 'node:path';
|
|
5
|
+
import { DoomainError } from './errors.js';
|
|
6
|
+
function runProcess(command, args, options) {
|
|
7
|
+
return new Promise((resolve, reject) => {
|
|
8
|
+
const child = spawn(command, args, {
|
|
9
|
+
...options,
|
|
10
|
+
stdio: ['ignore', 'pipe', 'pipe'],
|
|
11
|
+
windowsHide: true,
|
|
12
|
+
});
|
|
13
|
+
let stderr = '';
|
|
14
|
+
let stdout = '';
|
|
15
|
+
child.stderr.setEncoding('utf8');
|
|
16
|
+
child.stderr.on('data', (chunk) => {
|
|
17
|
+
stderr += chunk;
|
|
18
|
+
});
|
|
19
|
+
child.stdout.setEncoding('utf8');
|
|
20
|
+
child.stdout.on('data', (chunk) => {
|
|
21
|
+
stdout += chunk;
|
|
22
|
+
});
|
|
23
|
+
child.once('error', reject);
|
|
24
|
+
child.once('close', (exitCode) => resolve({ exitCode, stderr, stdout }));
|
|
25
|
+
});
|
|
26
|
+
}
|
|
27
|
+
export function npmInstallCommand(cacheDirectory, platform = process.platform, environment = process.env) {
|
|
28
|
+
const env = Object.fromEntries(Object.entries(environment).filter(([key]) => key.toLowerCase() !== 'npm_config_cache'));
|
|
29
|
+
env.npm_config_cache = cacheDirectory;
|
|
30
|
+
return {
|
|
31
|
+
command: 'npm',
|
|
32
|
+
args: ['install', '--global', 'doomain@latest', '--prefer-online', '--offline=false'],
|
|
33
|
+
options: {
|
|
34
|
+
env,
|
|
35
|
+
shell: platform === 'win32',
|
|
36
|
+
},
|
|
37
|
+
};
|
|
38
|
+
}
|
|
39
|
+
export async function installLatestVersion(options = {}) {
|
|
40
|
+
const cacheDirectory = await mkdtemp(join(options.cacheRoot ?? tmpdir(), 'doomain-npm-cache-'));
|
|
41
|
+
try {
|
|
42
|
+
const invocation = npmInstallCommand(cacheDirectory, options.platform);
|
|
43
|
+
const result = await (options.runner ?? runProcess)(invocation.command, invocation.args, invocation.options);
|
|
44
|
+
if (result.exitCode !== 0) {
|
|
45
|
+
const reason = result.stderr.trim() || result.stdout.trim() || `npm exited with code ${result.exitCode ?? 'unknown'}`;
|
|
46
|
+
throw new DoomainError('SELF_UPDATE_FAILED', `Unable to update doomain: ${reason}`);
|
|
47
|
+
}
|
|
48
|
+
return {
|
|
49
|
+
package: 'doomain',
|
|
50
|
+
packageSpec: 'doomain@latest',
|
|
51
|
+
packageManager: 'npm',
|
|
52
|
+
};
|
|
53
|
+
}
|
|
54
|
+
catch (error) {
|
|
55
|
+
if (error instanceof DoomainError)
|
|
56
|
+
throw error;
|
|
57
|
+
const message = error instanceof Error ? error.message : String(error);
|
|
58
|
+
throw new DoomainError('SELF_UPDATE_FAILED', `Unable to update doomain: ${message}`);
|
|
59
|
+
}
|
|
60
|
+
finally {
|
|
61
|
+
await rm(cacheDirectory, { force: true, recursive: true }).catch(() => undefined);
|
|
62
|
+
}
|
|
63
|
+
}
|
package/oclif.manifest.json
CHANGED
|
@@ -142,6 +142,68 @@
|
|
|
142
142
|
"schema.js"
|
|
143
143
|
]
|
|
144
144
|
},
|
|
145
|
+
"update": {
|
|
146
|
+
"aliases": [],
|
|
147
|
+
"args": {},
|
|
148
|
+
"description": "Install the latest doomain version from npm without using the existing npm cache.",
|
|
149
|
+
"examples": [
|
|
150
|
+
"<%= config.bin %> <%= command.id %>",
|
|
151
|
+
"<%= config.bin %> <%= command.id %> --json"
|
|
152
|
+
],
|
|
153
|
+
"flags": {
|
|
154
|
+
"json": {
|
|
155
|
+
"description": "Output a single JSON object and never prompt.",
|
|
156
|
+
"name": "json",
|
|
157
|
+
"allowNo": false,
|
|
158
|
+
"type": "boolean"
|
|
159
|
+
}
|
|
160
|
+
},
|
|
161
|
+
"hasDynamicHelp": false,
|
|
162
|
+
"hiddenAliases": [],
|
|
163
|
+
"id": "update",
|
|
164
|
+
"pluginAlias": "doomain",
|
|
165
|
+
"pluginName": "doomain",
|
|
166
|
+
"pluginType": "core",
|
|
167
|
+
"strict": true,
|
|
168
|
+
"enableJsonFlag": false,
|
|
169
|
+
"isESM": true,
|
|
170
|
+
"relativePath": [
|
|
171
|
+
"dist",
|
|
172
|
+
"commands",
|
|
173
|
+
"update.js"
|
|
174
|
+
]
|
|
175
|
+
},
|
|
176
|
+
"upgrade": {
|
|
177
|
+
"aliases": [],
|
|
178
|
+
"args": {},
|
|
179
|
+
"description": "Install the latest doomain version from npm without using the existing npm cache.",
|
|
180
|
+
"examples": [
|
|
181
|
+
"<%= config.bin %> <%= command.id %>",
|
|
182
|
+
"<%= config.bin %> <%= command.id %> --json"
|
|
183
|
+
],
|
|
184
|
+
"flags": {
|
|
185
|
+
"json": {
|
|
186
|
+
"description": "Output a single JSON object and never prompt.",
|
|
187
|
+
"name": "json",
|
|
188
|
+
"allowNo": false,
|
|
189
|
+
"type": "boolean"
|
|
190
|
+
}
|
|
191
|
+
},
|
|
192
|
+
"hasDynamicHelp": false,
|
|
193
|
+
"hiddenAliases": [],
|
|
194
|
+
"id": "upgrade",
|
|
195
|
+
"pluginAlias": "doomain",
|
|
196
|
+
"pluginName": "doomain",
|
|
197
|
+
"pluginType": "core",
|
|
198
|
+
"strict": true,
|
|
199
|
+
"enableJsonFlag": false,
|
|
200
|
+
"isESM": true,
|
|
201
|
+
"relativePath": [
|
|
202
|
+
"dist",
|
|
203
|
+
"commands",
|
|
204
|
+
"upgrade.js"
|
|
205
|
+
]
|
|
206
|
+
},
|
|
145
207
|
"verify": {
|
|
146
208
|
"aliases": [],
|
|
147
209
|
"args": {},
|
|
@@ -1001,5 +1063,5 @@
|
|
|
1001
1063
|
]
|
|
1002
1064
|
}
|
|
1003
1065
|
},
|
|
1004
|
-
"version": "0.1.
|
|
1066
|
+
"version": "0.1.21"
|
|
1005
1067
|
}
|