cloudflare/cloudflare-typescript

Public

mirrored fromhttps://github.com/cloudflare/cloudflare-typescriptAvailable

CodeCommitsIssuesPull requestsActionsInsightsSecurity
v7

Branches

Tags

  • No tags available.
0Branches0Tags
Go to file
Add file
Code

Clone

HTTPS

Download ZIP

bin/cli

52lines · modecode

1#!/usr/bin/env node
2
3const { spawnSync } = require('child_process');
4
5const commands = {
6 migrate: {
7 description: 'Run migrations to update to the latest major SDK version',
8 fn: () => {
9 const result = spawnSync(
10 'npx',
11 [
12 '-y',
13 'https://github.com/stainless-api/migrate-ts/releases/download/0.0.2/stainless-api-migrate-0.0.2-6.tgz',
14 '--migrationConfig',
15 require.resolve('./migration-config.json'),
16 ...process.argv.slice(3),
17 ],
18 { stdio: 'inherit' },
19 );
20 if (result.status !== 0) {
21 process.exit(result.status);
22 }
23 },
24 },
25};
26
27function exitWithHelp() {
28 console.log(`Usage: cloudflare <subcommand>`);
29 console.log();
30 console.log('Subcommands:');
31
32 for (const [name, info] of Object.entries(commands)) {
33 console.log(` ${name} ${info.description}`);
34 }
35
36 console.log();
37 process.exit(1);
38}
39
40if (process.argv.length < 3) {
41 exitWithHelp();
42}
43
44const commandName = process.argv[2];
45
46const command = commands[commandName];
47if (!command) {
48 console.log(`Unknown subcommand ${commandName}.`);
49 exitWithHelp();
50}
51
52command.fn();
53