@cloud-cli/dc 1.3.0 → 1.3.2

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@cloud-cli/dc",
3
- "version": "1.3.0",
3
+ "version": "1.3.2",
4
4
  "main": "./dist/index.js",
5
5
  "description": "Run services with docker compose",
6
6
  "type": "module",
@@ -25,7 +25,7 @@
25
25
  "@cloud-cli/exec": "latest"
26
26
  },
27
27
  "peerDependencies": {
28
- "@cloud-cli/cli": "latest"
28
+ "@cloud-cli/cli": "^2.2.0"
29
29
  },
30
30
  "devDependencies": {
31
31
  "@cloud-cli/prettier-config": "^1.0.0",
package/src/index.ts CHANGED
@@ -1,14 +1,14 @@
1
- import { getConfig, init, help } from '@cloud-cli/cli';
2
- import { exec } from '@cloud-cli/exec';
3
- import { existsSync, mkdirSync } from 'node:fs';
4
- import { readFile, readdir, rm, writeFile } from 'node:fs/promises';
5
- import { join } from 'node:path';
1
+ import { getConfig, init, help } from "@cloud-cli/cli";
2
+ import { exec } from "@cloud-cli/exec";
3
+ import { existsSync, mkdirSync } from "node:fs";
4
+ import { readFile, readdir, rm, writeFile } from "node:fs/promises";
5
+ import { join } from "node:path";
6
6
 
7
- const config = getConfig('dc', { storagePath: 'docker-compose' });
7
+ const config = getConfig("dc", { storagePath: "docker-compose" });
8
8
  const storagePath = join(process.cwd(), config.storagePath);
9
- const notFoundError = new Error('Service not found');
9
+ const notFoundError = new Error("Service not found");
10
10
  const binaryAndArgs = {
11
- binary: '',
11
+ binary: "",
12
12
  args: [],
13
13
  };
14
14
 
@@ -17,10 +17,10 @@ interface CliOptions {
17
17
  content?: string;
18
18
  }
19
19
 
20
- const getPath = (name) => join(storagePath, name + '.yml');
20
+ const getPath = (name) => join(storagePath, name + ".yml");
21
21
  const checkName = (name) => {
22
22
  if (!name) {
23
- throw new Error('Name is required');
23
+ throw new Error("Name is required");
24
24
  }
25
25
 
26
26
  // TODO sanitize file name
@@ -35,7 +35,7 @@ async function stop(options: CliOptions) {
35
35
  throw notFoundError;
36
36
  }
37
37
 
38
- const out = await exec(binaryAndArgs.binary, [...binaryAndArgs.args, '-f', path, 'down'].filter(Boolean));
38
+ const out = await exec(binaryAndArgs.binary, [...binaryAndArgs.args, "-f", path, "down"].filter(Boolean));
39
39
 
40
40
  if (out.ok) {
41
41
  return true;
@@ -52,7 +52,7 @@ async function start(options: CliOptions) {
52
52
  throw notFoundError;
53
53
  }
54
54
 
55
- const out = await exec(binaryAndArgs.binary, [...binaryAndArgs.args, '-f', path, 'up', '-d'].filter(Boolean));
55
+ const out = await exec(binaryAndArgs.binary, [...binaryAndArgs.args, "-f", path, "up", "-d"].filter(Boolean));
56
56
 
57
57
  if (out.ok) {
58
58
  return true;
@@ -66,7 +66,7 @@ async function update(options: CliOptions) {
66
66
  const { content } = options;
67
67
 
68
68
  if (!content) {
69
- throw new Error('docker compose content is required');
69
+ throw new Error("docker compose content is required");
70
70
  }
71
71
 
72
72
  const path = getPath(name);
@@ -87,7 +87,7 @@ async function remove(options: CliOptions) {
87
87
 
88
88
  async function list() {
89
89
  const files = await readdir(storagePath, { withFileTypes: true });
90
- return files.filter((f) => f.isFile()).map((f) => f.name.replace('.yml', ''));
90
+ return files.filter((f) => f.isFile()).map((f) => f.name.replace(".yml", ""));
91
91
  }
92
92
 
93
93
  async function show(options: CliOptions) {
@@ -95,7 +95,7 @@ async function show(options: CliOptions) {
95
95
  const path = getPath(name);
96
96
 
97
97
  if (existsSync(path)) {
98
- const content = await readFile(path, 'utf-8');
98
+ const content = await readFile(path, "utf-8");
99
99
  return { name, content };
100
100
  }
101
101
 
@@ -106,31 +106,31 @@ export default {
106
106
  async [init]() {
107
107
  mkdirSync(storagePath, { recursive: true });
108
108
 
109
- const docker = await exec('docker', ['compose']);
109
+ const docker = await exec("docker", ["compose"]);
110
110
  if (docker.ok) {
111
- binaryAndArgs.binary = 'docker';
112
- binaryAndArgs.args.push('compose');
111
+ binaryAndArgs.binary = "docker";
112
+ binaryAndArgs.args.push("compose");
113
113
  return;
114
114
  }
115
115
 
116
- const dockerCompose = await exec('docker-compose', ['--help']);
116
+ const dockerCompose = await exec("docker-compose", ["--help"]);
117
117
  if (dockerCompose.ok) {
118
- binaryAndArgs.binary = 'docker-compose';
118
+ binaryAndArgs.binary = "docker-compose";
119
119
  return;
120
120
  }
121
121
 
122
- binaryAndArgs.binary = 'exit';
123
- binaryAndArgs.args.push('1');
122
+ binaryAndArgs.binary = "exit";
123
+ binaryAndArgs.args.push("1");
124
124
  },
125
125
  [help]: () => `Manage Docker Compose services
126
126
 
127
127
  Available commands:
128
- start - Start services (optional name to start specific service)
129
- stop - Stop services (optional name to stop specific service)
130
- update - Update Docker Compose services
131
- remove - Remove a Compose file
132
- show - Show content of a Compose file
133
- list - List Compose files/services
128
+ dc.start --name <name> - Start a Compose service
129
+ dc.stop --name <name> - Stop a Compose service
130
+ dc.update --name <name> --content <yaml> - Create or update a Compose file
131
+ dc.remove --name <name> - Remove a Compose file
132
+ dc.show --name <name> - Show a Compose file
133
+ dc.list - List Compose files/services
134
134
 
135
135
  Options:
136
136
  name - Service/Compose file name
@@ -1,10 +0,0 @@
1
- name: CICD
2
- on:
3
- push:
4
-
5
- jobs:
6
- release:
7
- uses: cloud-cli/workflows/.github/workflows/npm-build-release.yml@main
8
- secrets:
9
- NPM_TOKEN: ${{ secrets.NPM_TOKEN }}
10
- GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}