@laioutr/cli 0.2.1 → 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/README.md CHANGED
@@ -20,7 +20,7 @@ $ npm install -g @laioutr/cli
20
20
  $ laioutr COMMAND
21
21
  running command...
22
22
  $ laioutr (--version)
23
- @laioutr/cli/0.2.1 darwin-arm64 node-v22.12.0
23
+ @laioutr/cli/0.3.0 darwin-arm64 node-v22.12.0
24
24
  $ laioutr --help [COMMAND]
25
25
  USAGE
26
26
  $ laioutr COMMAND
@@ -43,6 +43,8 @@ USAGE
43
43
  * [`laioutr plugins unlink [PLUGIN]`](#laioutr-plugins-unlink-plugin)
44
44
  * [`laioutr plugins update`](#laioutr-plugins-update)
45
45
  * [`laioutr project fetch-rc [FILENAME]`](#laioutr-project-fetch-rc-filename)
46
+ * [`laioutr rc fetch [FILENAME]`](#laioutr-rc-fetch-filename)
47
+ * [`laioutr rc update [FILENAME]`](#laioutr-rc-update-filename)
46
48
 
47
49
  ## `laioutr help [COMMAND]`
48
50
 
@@ -372,9 +374,58 @@ FLAGS
372
374
  DESCRIPTION
373
375
  Fetches the laioutrrc.json of a project from the cockpit api.
374
376
 
377
+ ALIASES
378
+ $ laioutr project fetch-rc
379
+
375
380
  EXAMPLES
376
381
  $ laioutr project fetch-rc
377
382
  ```
378
383
 
379
- _See code: [src/commands/project/fetch-rc.ts](https://github.com/packages/cli/blob/v0.2.1/src/commands/project/fetch-rc.ts)_
384
+ ## `laioutr rc fetch [FILENAME]`
385
+
386
+ Fetches the laioutrrc.json of a project from the cockpit api.
387
+
388
+ ```
389
+ USAGE
390
+ $ laioutr rc fetch [FILENAME] --cockpitApiHost <value> --cwd <value> -e <value> -s <value> -p <value>
391
+
392
+ FLAGS
393
+ -e, --environmentName=<value> (required) [default: main] environment name
394
+ -p, --project=<value> (required) <organization slug>/<project slug>
395
+ -s, --projectSecret=<value> (required) project secret
396
+ --cockpitApiHost=<value> (required) [default: https://cockpit.laioutr.cloud] cockpit api host
397
+ --cwd=<value> (required) [default: /Users/sl/src/laioutr/apps/cli] current working directory
398
+
399
+ DESCRIPTION
400
+ Fetches the laioutrrc.json of a project from the cockpit api.
401
+
402
+ ALIASES
403
+ $ laioutr project fetch-rc
404
+
405
+ EXAMPLES
406
+ $ laioutr rc fetch
407
+ ```
408
+
409
+ _See code: [src/commands/rc/fetch.ts](https://github.com/packages/cli/blob/v0.3.0/src/commands/rc/fetch.ts)_
410
+
411
+ ## `laioutr rc update [FILENAME]`
412
+
413
+ Updates an existing laioutrrc.json file with the latest from the cockpit api.
414
+
415
+ ```
416
+ USAGE
417
+ $ laioutr rc update [FILENAME] --cockpitApiHost <value> --cwd <value>
418
+
419
+ FLAGS
420
+ --cockpitApiHost=<value> (required) [default: https://cockpit.laioutr.cloud] cockpit api host
421
+ --cwd=<value> (required) [default: /Users/sl/src/laioutr/apps/cli] current working directory
422
+
423
+ DESCRIPTION
424
+ Updates an existing laioutrrc.json file with the latest from the cockpit api.
425
+
426
+ EXAMPLES
427
+ $ laioutr rc update
428
+ ```
429
+
430
+ _See code: [src/commands/rc/update.ts](https://github.com/packages/cli/blob/v0.3.0/src/commands/rc/update.ts)_
380
431
  <!-- commandsstop -->
@@ -0,0 +1,10 @@
1
+ interface HostApiOptions {
2
+ cockpitApiHost: string;
3
+ }
4
+ export interface ProjectApiOptions extends HostApiOptions {
5
+ project: string;
6
+ projectSecret: string;
7
+ environmentName: string;
8
+ }
9
+ export declare const fetchRc: (flags: ProjectApiOptions) => Promise<string>;
10
+ export {};
@@ -0,0 +1,28 @@
1
+ import { z } from 'zod/v4';
2
+ const apiResponseSchema = z.object({
3
+ content: z.string(),
4
+ });
5
+ export const fetchRc = async (flags) => {
6
+ const url = `${flags.cockpitApiHost}/api/v1/project/fetch-rc`;
7
+ const [organizationSlug, projectSlug] = flags.project.split('/');
8
+ const response = await fetch(url, {
9
+ body: JSON.stringify({
10
+ environmentName: flags.environmentName,
11
+ organizationSlug,
12
+ projectSecret: flags.projectSecret,
13
+ projectSlug,
14
+ }),
15
+ headers: {
16
+ 'Content-Type': 'application/json',
17
+ },
18
+ method: 'POST',
19
+ });
20
+ const data = await response.json();
21
+ if (response.status !== 200) {
22
+ // eslint-disable-next-line no-console
23
+ console.error(data);
24
+ throw new Error('Failed to fetch RC file. See error message above.');
25
+ }
26
+ const parsed = apiResponseSchema.parse(data);
27
+ return parsed.content;
28
+ };
@@ -1,5 +1,5 @@
1
1
  import LaioutrBaseCommand from '../../laioutr-base-command.js';
2
- export default class ProjectFetchRc extends LaioutrBaseCommand {
2
+ export default class ProjectRcFetch extends LaioutrBaseCommand {
3
3
  static args: {
4
4
  fileName: import("@oclif/core/interfaces").Arg<string, Record<string, unknown>>;
5
5
  };
@@ -12,6 +12,7 @@ export default class ProjectFetchRc extends LaioutrBaseCommand {
12
12
  cockpitApiHost: import("@oclif/core/interfaces").OptionFlag<string, import("@oclif/core/interfaces").CustomOptions>;
13
13
  cwd: import("@oclif/core/interfaces").OptionFlag<string, import("@oclif/core/interfaces").CustomOptions>;
14
14
  };
15
+ static aliases: string[];
16
+ static deprecateAliases: boolean;
15
17
  run(): Promise<void>;
16
- private fetchRc;
17
18
  }
@@ -0,0 +1,28 @@
1
+ import { writeFile } from 'node:fs/promises';
2
+ import path from 'node:path';
3
+ import { Args, Flags } from '@oclif/core';
4
+ import { fetchRc } from '../../api/fetchRc.js';
5
+ import LaioutrBaseCommand from '../../laioutr-base-command.js';
6
+ export default class ProjectRcFetch extends LaioutrBaseCommand {
7
+ static args = {
8
+ ...LaioutrBaseCommand.args,
9
+ fileName: Args.string({ default: 'laioutrrc.json', name: 'fileName', required: false }),
10
+ };
11
+ static description = 'Fetches the laioutrrc.json of a project from the cockpit api.';
12
+ static examples = ['<%= config.bin %> <%= command.id %>'];
13
+ static flags = {
14
+ ...LaioutrBaseCommand.flags,
15
+ environmentName: Flags.string({ char: 'e', default: 'main', description: 'environment name', env: 'ENVIRONMENT_NAME', required: true }),
16
+ projectSecret: Flags.string({ char: 's', description: 'project secret', env: 'PROJECT_SECRET', required: true }),
17
+ project: Flags.string({ char: 'p', description: '<organization slug>/<project slug>', env: 'PROJECT', required: true }),
18
+ };
19
+ static aliases = ['project:fetch-rc'];
20
+ static deprecateAliases = true;
21
+ async run() {
22
+ const { args, flags } = await this.parse(ProjectRcFetch);
23
+ const rc = await fetchRc(flags);
24
+ const filePath = path.join(flags.cwd, args.fileName);
25
+ this.log('Writing RC file', filePath);
26
+ return writeFile(filePath, rc);
27
+ }
28
+ }
@@ -0,0 +1,13 @@
1
+ import LaioutrBaseCommand from '../../laioutr-base-command.js';
2
+ export default class ProjectRcUpdate extends LaioutrBaseCommand {
3
+ static args: {
4
+ fileName: import("@oclif/core/interfaces").Arg<string, Record<string, unknown>>;
5
+ };
6
+ static description: string;
7
+ static examples: string[];
8
+ static flags: {
9
+ cockpitApiHost: import("@oclif/core/interfaces").OptionFlag<string, import("@oclif/core/interfaces").CustomOptions>;
10
+ cwd: import("@oclif/core/interfaces").OptionFlag<string, import("@oclif/core/interfaces").CustomOptions>;
11
+ };
12
+ run(): Promise<void>;
13
+ }
@@ -0,0 +1,33 @@
1
+ import { readFile, writeFile } from 'node:fs/promises';
2
+ import path from 'node:path';
3
+ import { Args } from '@oclif/core';
4
+ import { fetchRc } from '../../api/fetchRc.js';
5
+ import LaioutrBaseCommand from '../../laioutr-base-command.js';
6
+ import { rcWithLaioutrMetaSchema } from '../../rc/validation.js';
7
+ export default class ProjectRcUpdate extends LaioutrBaseCommand {
8
+ static args = {
9
+ ...LaioutrBaseCommand.args,
10
+ fileName: Args.string({ default: 'laioutrrc.json', name: 'fileName', required: false }),
11
+ };
12
+ static description = 'Updates an existing laioutrrc.json file with the latest from the cockpit api.';
13
+ static examples = ['<%= config.bin %> <%= command.id %>'];
14
+ static flags = {
15
+ ...LaioutrBaseCommand.flags,
16
+ };
17
+ async run() {
18
+ const { args, flags } = await this.parse(ProjectRcUpdate);
19
+ const currentRcRaw = await readFile(path.join(flags.cwd, args.fileName), 'utf-8');
20
+ const currentRc = rcWithLaioutrMetaSchema.parse(JSON.parse(currentRcRaw));
21
+ const options = {
22
+ ...flags,
23
+ project: currentRc.laioutr.projectSlug,
24
+ projectSecret: currentRc.laioutr.projectSecretKey,
25
+ environmentName: currentRc.laioutr.environmentName,
26
+ };
27
+ this.log('Fetching latest RC for project', options.project);
28
+ const rc = await fetchRc(options);
29
+ const filePath = path.join(flags.cwd, args.fileName);
30
+ this.log('Writing RC file', filePath);
31
+ return writeFile(filePath, rc);
32
+ }
33
+ }
@@ -0,0 +1,8 @@
1
+ import z from 'zod/v4';
2
+ export declare const rcWithLaioutrMetaSchema: z.ZodObject<{
3
+ laioutr: z.ZodObject<{
4
+ projectSecretKey: z.ZodString;
5
+ projectSlug: z.ZodString;
6
+ environmentName: z.ZodString;
7
+ }, z.core.$strip>;
8
+ }, z.core.$strip>;
@@ -0,0 +1,8 @@
1
+ import z from 'zod/v4';
2
+ export const rcWithLaioutrMetaSchema = z.object({
3
+ laioutr: z.object({
4
+ projectSecretKey: z.string(),
5
+ projectSlug: z.string(),
6
+ environmentName: z.string(),
7
+ }),
8
+ });
@@ -1,7 +1,9 @@
1
1
  {
2
2
  "commands": {
3
- "project:fetch-rc": {
4
- "aliases": [],
3
+ "rc:fetch": {
4
+ "aliases": [
5
+ "project:fetch-rc"
6
+ ],
5
7
  "args": {
6
8
  "fileName": {
7
9
  "default": "laioutrrc.json",
@@ -9,6 +11,7 @@
9
11
  "required": false
10
12
  }
11
13
  },
14
+ "deprecateAliases": true,
12
15
  "description": "Fetches the laioutrrc.json of a project from the cockpit api.",
13
16
  "examples": [
14
17
  "<%= config.bin %> <%= command.id %>"
@@ -68,7 +71,58 @@
68
71
  },
69
72
  "hasDynamicHelp": false,
70
73
  "hiddenAliases": [],
71
- "id": "project:fetch-rc",
74
+ "id": "rc:fetch",
75
+ "pluginAlias": "@laioutr/cli",
76
+ "pluginName": "@laioutr/cli",
77
+ "pluginType": "core",
78
+ "strict": true,
79
+ "enableJsonFlag": false,
80
+ "isESM": true,
81
+ "relativePath": [
82
+ "dist",
83
+ "commands",
84
+ "rc",
85
+ "fetch.js"
86
+ ]
87
+ },
88
+ "rc:update": {
89
+ "aliases": [],
90
+ "args": {
91
+ "fileName": {
92
+ "default": "laioutrrc.json",
93
+ "name": "fileName",
94
+ "required": false
95
+ }
96
+ },
97
+ "description": "Updates an existing laioutrrc.json file with the latest from the cockpit api.",
98
+ "examples": [
99
+ "<%= config.bin %> <%= command.id %>"
100
+ ],
101
+ "flags": {
102
+ "cockpitApiHost": {
103
+ "description": "cockpit api host",
104
+ "env": "COCKPIT_API_HOST",
105
+ "name": "cockpitApiHost",
106
+ "required": true,
107
+ "default": "https://cockpit.laioutr.cloud",
108
+ "hasDynamicHelp": false,
109
+ "multiple": false,
110
+ "type": "option"
111
+ },
112
+ "cwd": {
113
+ "description": "current working directory",
114
+ "env": "CWD",
115
+ "name": "cwd",
116
+ "required": true,
117
+ "default": "/Users/sl/src/laioutr/apps/cli",
118
+ "hasDynamicHelp": false,
119
+ "multiple": false,
120
+ "type": "option"
121
+ }
122
+ },
123
+ "hasDynamicHelp": false,
124
+ "hiddenAliases": [],
125
+ "id": "rc:update",
72
126
  "pluginAlias": "@laioutr/cli",
73
127
  "pluginName": "@laioutr/cli",
74
128
  "pluginType": "core",
@@ -78,10 +132,10 @@
78
132
  "relativePath": [
79
133
  "dist",
80
134
  "commands",
81
- "project",
82
- "fetch-rc.js"
135
+ "rc",
136
+ "update.js"
83
137
  ]
84
138
  }
85
139
  },
86
- "version": "0.2.1"
140
+ "version": "0.3.0"
87
141
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@laioutr/cli",
3
- "version": "0.2.1",
3
+ "version": "0.3.0",
4
4
  "description": "Laioutr CLI",
5
5
  "repository": "packages/cli",
6
6
  "author": "Laioutr GmbH",
@@ -1,52 +0,0 @@
1
- import { writeFile } from 'node:fs/promises';
2
- import path from 'node:path';
3
- import { Args, Flags } from '@oclif/core';
4
- import { z } from 'zod/v4';
5
- import LaioutrBaseCommand from '../../laioutr-base-command.js';
6
- const apiResponseSchema = z.object({
7
- content: z.string(),
8
- });
9
- export default class ProjectFetchRc extends LaioutrBaseCommand {
10
- static args = {
11
- ...LaioutrBaseCommand.args,
12
- fileName: Args.string({ default: 'laioutrrc.json', name: 'fileName', required: false }),
13
- };
14
- static description = 'Fetches the laioutrrc.json of a project from the cockpit api.';
15
- static examples = ['<%= config.bin %> <%= command.id %>'];
16
- static flags = {
17
- ...LaioutrBaseCommand.flags,
18
- environmentName: Flags.string({ char: 'e', default: 'main', description: 'environment name', env: 'ENVIRONMENT_NAME', required: true }),
19
- projectSecret: Flags.string({ char: 's', description: 'project secret', env: 'PROJECT_SECRET', required: true }),
20
- project: Flags.string({ char: 'p', description: '<organization slug>/<project slug>', env: 'PROJECT', required: true }),
21
- };
22
- async run() {
23
- const { args, flags } = await this.parse(ProjectFetchRc);
24
- const rc = await this.fetchRc(flags);
25
- const filePath = path.join(flags.cwd, args.fileName);
26
- this.log('Writing RC file', filePath);
27
- return writeFile(filePath, rc);
28
- }
29
- async fetchRc(flags) {
30
- const url = `${flags.cockpitApiHost}/api/v1/project/fetch-rc`;
31
- const [organizationSlug, projectSlug] = flags.project.split('/');
32
- const response = await fetch(url, {
33
- body: JSON.stringify({
34
- environmentName: flags.environmentName,
35
- organizationSlug,
36
- projectSecret: flags.projectSecret,
37
- projectSlug,
38
- }),
39
- headers: {
40
- 'Content-Type': 'application/json',
41
- },
42
- method: 'POST',
43
- });
44
- const data = await response.json();
45
- if (response.status !== 200) {
46
- this.log(data);
47
- this.error('Failed to fetch RC file. See error message above.', { exit: 1 });
48
- }
49
- const parsed = apiResponseSchema.parse(data);
50
- return parsed.content;
51
- }
52
- }