@gotillit/tllt 0.3.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/AGENTS.md +59 -0
- package/README.MD +106 -0
- package/configure.js +243 -0
- package/deploy.js +289 -0
- package/diff.js +158 -0
- package/docs/apis.md +73 -0
- package/docs/authentication.md +53 -0
- package/docs/commands.md +135 -0
- package/docs/scheduler.md +173 -0
- package/docs/schemas.md +73 -0
- package/docs/workflow.md +86 -0
- package/import.js +580 -0
- package/lib/apis.js +39 -0
- package/lib/auth.js +123 -0
- package/lib/client.js +52 -0
- package/lib/config.js +209 -0
- package/lib/output.js +51 -0
- package/lib/scheduler-entities.js +404 -0
- package/lib/schema.js +65 -0
- package/package.json +37 -0
- package/schema.js +79 -0
- package/tllt.js +112 -0
package/tllt.js
ADDED
|
@@ -0,0 +1,112 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
import {Command} from 'commander';
|
|
3
|
+
|
|
4
|
+
import doConfigure from './configure.js';
|
|
5
|
+
import doImport from './import.js';
|
|
6
|
+
import doDiff from './diff.js';
|
|
7
|
+
import doDeploy from './deploy.js';
|
|
8
|
+
import doSchema from './schema.js';
|
|
9
|
+
import {listProfiles} from './lib/config.js';
|
|
10
|
+
import {setJsonMode, run, result, info} from './lib/output.js';
|
|
11
|
+
|
|
12
|
+
const program = new Command();
|
|
13
|
+
|
|
14
|
+
program
|
|
15
|
+
.name('tllt')
|
|
16
|
+
.description(
|
|
17
|
+
[
|
|
18
|
+
'TilliT CLI — manage TilliT configuration for the Digital Operations and Scheduler APIs.',
|
|
19
|
+
'',
|
|
20
|
+
'First run (bootstrap a connection):',
|
|
21
|
+
' npx @gotillit/tllt configure',
|
|
22
|
+
'',
|
|
23
|
+
'A connection is identified by environment + tenant, so you can keep several',
|
|
24
|
+
'(e.g. client1 on prod and client2 on stage) and select one with --profile.',
|
|
25
|
+
'',
|
|
26
|
+
'Agents: read AGENTS.md and docs/ to learn the tool; pass --json for machine output.',
|
|
27
|
+
].join('\n')
|
|
28
|
+
)
|
|
29
|
+
.version('0.3.0')
|
|
30
|
+
.option('-p, --profile <name>', 'connection profile to use (default: the configured default)')
|
|
31
|
+
.option('--json', 'emit machine-readable JSON on stdout (agent-friendly)');
|
|
32
|
+
|
|
33
|
+
// Apply global flags before any subcommand action runs.
|
|
34
|
+
program.hook('preAction', (thisCommand, actionCommand) => {
|
|
35
|
+
const globals = thisCommand.opts();
|
|
36
|
+
setJsonMode(globals.json);
|
|
37
|
+
// Make --profile available to subcommands that don't declare it themselves.
|
|
38
|
+
const merged = actionCommand.opts();
|
|
39
|
+
if (globals.profile && !merged.profile) actionCommand.setOptionValue('profile', globals.profile);
|
|
40
|
+
});
|
|
41
|
+
|
|
42
|
+
program
|
|
43
|
+
.command('configure')
|
|
44
|
+
.alias('init')
|
|
45
|
+
.description('Bootstrap (or update) a connection — interactive, or fully flag-driven')
|
|
46
|
+
.option('-t, --tenant <tenant>', 'tenant name')
|
|
47
|
+
.option('-e, --environment <env>', 'environment: prod | stage | sandbox | dev | enterprise')
|
|
48
|
+
.option('--enterprise <name>', 'enterprise name (when --environment enterprise), e.g. acme')
|
|
49
|
+
.option('--tier <tier>', 'enterprise tier: prod | stage | dev (default stage)')
|
|
50
|
+
.option('-a, --auth <method>', 'auth method: basic | apikey')
|
|
51
|
+
.option('-u, --username <username>', 'basic auth username')
|
|
52
|
+
.option('-w, --password <password>', 'basic auth password')
|
|
53
|
+
.option('--api-key <key>', 'apikey auth: Cognito app client id')
|
|
54
|
+
.option('--api-secret <secret>', 'apikey auth: Cognito app client secret')
|
|
55
|
+
.option('--token-url <url>', 'apikey auth: Cognito OAuth2 token endpoint')
|
|
56
|
+
.option('--scopes <list>', 'apikey auth: comma-separated OAuth scopes')
|
|
57
|
+
.option('--base-url <url>', 'override the derived base URL')
|
|
58
|
+
.option('--default', 'make this the default connection')
|
|
59
|
+
.action(run((opts) => doConfigure(opts)));
|
|
60
|
+
|
|
61
|
+
program
|
|
62
|
+
.command('profiles')
|
|
63
|
+
.alias('connections')
|
|
64
|
+
.description('List configured connections')
|
|
65
|
+
.action(
|
|
66
|
+
run(() => {
|
|
67
|
+
const profiles = listProfiles();
|
|
68
|
+
for (const p of profiles) {
|
|
69
|
+
info(`${p.isDefault ? '*' : ' '} ${p.name} [${p.method}] ${p.baseUrl}`);
|
|
70
|
+
}
|
|
71
|
+
if (profiles.length === 0) info('No connections yet. Run `tllt configure`.');
|
|
72
|
+
result(null, {ok: true, profiles});
|
|
73
|
+
})
|
|
74
|
+
);
|
|
75
|
+
|
|
76
|
+
program
|
|
77
|
+
.command('schema')
|
|
78
|
+
.description('Describe an entity data model (fields, types, required, enums, references)')
|
|
79
|
+
.argument('[entity]', 'entity name, e.g. Asset (omit to list all entities)')
|
|
80
|
+
.option('--api <api>', 'force the API: do | scheduler')
|
|
81
|
+
.action(run((entity, opts) => doSchema({...opts, entity})));
|
|
82
|
+
|
|
83
|
+
program
|
|
84
|
+
.command('import')
|
|
85
|
+
.description('Snapshot the current configuration of a connection into local files')
|
|
86
|
+
.option('--api <api>', 'limit to a single API: do | scheduler')
|
|
87
|
+
.option('-d, --dir <path>', 'output directory (default: current directory)')
|
|
88
|
+
.action(run((opts) => doImport(opts)));
|
|
89
|
+
|
|
90
|
+
program
|
|
91
|
+
.command('diff')
|
|
92
|
+
.description('Compare two snapshots and show the changeset (from → to)')
|
|
93
|
+
.requiredOption('-f, --from <profile>', 'source snapshot (desired state)')
|
|
94
|
+
.requiredOption('-t, --to <profile>', 'target snapshot (to be changed)')
|
|
95
|
+
.option('-o, --out <file>', 'write the changeset JSON to a file')
|
|
96
|
+
.option('-d, --dir <path>', 'snapshots directory (default: current directory)')
|
|
97
|
+
.action(run((opts) => doDiff(opts)));
|
|
98
|
+
|
|
99
|
+
program
|
|
100
|
+
.command('deploy')
|
|
101
|
+
.description('Apply the difference between two snapshots to the live target')
|
|
102
|
+
.option('-f, --from <profile>', 'source snapshot (desired state)')
|
|
103
|
+
.requiredOption('-t, --to <profile>', 'target connection to change')
|
|
104
|
+
.option('--changeset <file>', 'apply a saved changeset instead of computing one')
|
|
105
|
+
.option('--api <api>', 'limit to a single API: do | scheduler')
|
|
106
|
+
.option('--dry-run', 'show what would change without applying')
|
|
107
|
+
.option('--prune', 'also delete target records missing from the source (destructive)')
|
|
108
|
+
.option('-y, --yes', 'skip the confirmation prompt')
|
|
109
|
+
.option('-d, --dir <path>', 'snapshots directory (default: current directory)')
|
|
110
|
+
.action(run((opts) => doDeploy(opts)));
|
|
111
|
+
|
|
112
|
+
program.parseAsync();
|