@lishugupta652/dokploy 0.1.5 → 0.1.6
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/CHANGELOG.md +16 -0
- package/README.md +234 -37
- package/package.json +3 -2
- package/scripts/ensure-publish-version.mjs +162 -0
- package/scripts/publish.sh +25 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,20 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
+
## 0.1.6 - 2026-04-13
|
|
4
|
+
|
|
5
|
+
_Initial changelog generated from repository history._
|
|
6
|
+
|
|
7
|
+
### Fixes
|
|
8
|
+
|
|
9
|
+
- scripts (691cf33)
|
|
10
|
+
- scripts (2930c10)
|
|
11
|
+
|
|
12
|
+
### Other Changes
|
|
13
|
+
|
|
14
|
+
- test (9ab9e57)
|
|
15
|
+
- add script for deployment (c511505)
|
|
16
|
+
- first commit (3f5e457)
|
|
17
|
+
|
|
3
18
|
## 0.1.5 - 2026-04-13
|
|
4
19
|
|
|
5
20
|
_Initial changelog generated from repository history._
|
|
@@ -10,6 +25,7 @@ _Initial changelog generated from repository history._
|
|
|
10
25
|
|
|
11
26
|
### Other Changes
|
|
12
27
|
|
|
28
|
+
- test (9ab9e57)
|
|
13
29
|
- add script for deployment (c511505)
|
|
14
30
|
- first commit (3f5e457)
|
|
15
31
|
|
package/README.md
CHANGED
|
@@ -1,30 +1,44 @@
|
|
|
1
|
-
# Dokploy
|
|
1
|
+
# Dokploy CLI
|
|
2
2
|
|
|
3
|
-
YAML-driven CLI for
|
|
3
|
+
YAML-driven CLI for managing Dokploy projects through the Dokploy API.
|
|
4
4
|
|
|
5
|
-
|
|
5
|
+
Use it locally or in CI to inspect projects, create/update applications, attach domains, deploy compose stacks, provision databases, and trigger redeploys without relying on the Terraform provider.
|
|
6
6
|
|
|
7
|
-
|
|
8
|
-
npm install
|
|
9
|
-
npm run build
|
|
10
|
-
```
|
|
7
|
+
## Features
|
|
11
8
|
|
|
12
|
-
|
|
9
|
+
- Inspect all Dokploy projects with `project.all`.
|
|
10
|
+
- Apply a declarative YAML config.
|
|
11
|
+
- Manage projects, environments, applications, compose stacks, databases, domains, backups, and volume backups.
|
|
12
|
+
- Trigger app or compose redeploys.
|
|
13
|
+
- Keep a small local `dokploy-state.json` file for resource IDs.
|
|
14
|
+
- Use colored terminal output with a raw JSON option for scripts.
|
|
15
|
+
- Accept either a Dokploy root URL or `/api` URL.
|
|
13
16
|
|
|
14
|
-
|
|
15
|
-
npm run dev -- apply -f examples/simple-app.yaml --dry-run
|
|
16
|
-
```
|
|
17
|
+
## Requirements
|
|
17
18
|
|
|
18
|
-
|
|
19
|
+
- Node.js 18 or newer
|
|
20
|
+
- A running Dokploy instance
|
|
21
|
+
- A Dokploy API key
|
|
19
22
|
|
|
20
|
-
|
|
23
|
+
The API key is read only from `DOKPLOY_API_KEY`. Do not put it in YAML config.
|
|
24
|
+
|
|
25
|
+
## Install
|
|
26
|
+
|
|
27
|
+
Global install:
|
|
21
28
|
|
|
22
29
|
```bash
|
|
23
30
|
npm install -g @lishugupta652/dokploy
|
|
24
31
|
dokploy --help
|
|
25
32
|
```
|
|
26
33
|
|
|
27
|
-
|
|
34
|
+
One-off use with npm:
|
|
35
|
+
|
|
36
|
+
```bash
|
|
37
|
+
npx @lishugupta652/dokploy --help
|
|
38
|
+
npx @lishugupta652/dokploy projects --host https://your-dokploy.example.com
|
|
39
|
+
```
|
|
40
|
+
|
|
41
|
+
Local project install:
|
|
28
42
|
|
|
29
43
|
```bash
|
|
30
44
|
npm install @lishugupta652/dokploy
|
|
@@ -32,59 +46,248 @@ npx dokploy --help
|
|
|
32
46
|
npm exec dokploy -- --help
|
|
33
47
|
```
|
|
34
48
|
|
|
35
|
-
##
|
|
49
|
+
## Authentication
|
|
36
50
|
|
|
37
51
|
```bash
|
|
38
52
|
export DOKPLOY_API_KEY=your-api-key
|
|
39
|
-
export DOKPLOY_HOST=https://your-dokploy.example.com
|
|
53
|
+
export DOKPLOY_HOST=https://your-dokploy.example.com
|
|
54
|
+
```
|
|
55
|
+
|
|
56
|
+
`DOKPLOY_HOST` is optional when `host` is set in `dokploy.yaml`.
|
|
57
|
+
|
|
58
|
+
Both forms work:
|
|
59
|
+
|
|
60
|
+
```bash
|
|
61
|
+
https://your-dokploy.example.com
|
|
62
|
+
https://your-dokploy.example.com/api
|
|
63
|
+
```
|
|
64
|
+
|
|
65
|
+
The CLI normalizes root hosts to `/api`.
|
|
66
|
+
|
|
67
|
+
## Quick Start
|
|
68
|
+
|
|
69
|
+
1. Check your API connection:
|
|
70
|
+
|
|
71
|
+
```bash
|
|
72
|
+
dokploy projects --host https://your-dokploy.example.com --summary
|
|
73
|
+
```
|
|
74
|
+
|
|
75
|
+
2. Create a starter config:
|
|
76
|
+
|
|
77
|
+
```bash
|
|
78
|
+
dokploy init
|
|
40
79
|
```
|
|
41
80
|
|
|
42
|
-
|
|
81
|
+
3. Edit `dokploy.yaml`.
|
|
82
|
+
|
|
83
|
+
4. Preview the changes:
|
|
84
|
+
|
|
85
|
+
```bash
|
|
86
|
+
dokploy apply -f dokploy.yaml --dry-run
|
|
87
|
+
```
|
|
88
|
+
|
|
89
|
+
5. Apply the config:
|
|
90
|
+
|
|
91
|
+
```bash
|
|
92
|
+
dokploy apply -f dokploy.yaml
|
|
93
|
+
```
|
|
94
|
+
|
|
95
|
+
6. Check status:
|
|
96
|
+
|
|
97
|
+
```bash
|
|
98
|
+
dokploy status -f dokploy.yaml
|
|
99
|
+
```
|
|
43
100
|
|
|
44
101
|
## Commands
|
|
45
102
|
|
|
46
103
|
```bash
|
|
47
|
-
dokploy projects --host https://your-dokploy.example.com/api
|
|
48
|
-
dokploy projects --summary --host https://your-dokploy.example.com/api
|
|
49
|
-
dokploy projects --json --host https://your-dokploy.example.com/api
|
|
50
104
|
dokploy projects --host https://your-dokploy.example.com
|
|
105
|
+
dokploy projects --summary --host https://your-dokploy.example.com
|
|
106
|
+
dokploy projects --json --host https://your-dokploy.example.com
|
|
107
|
+
|
|
108
|
+
dokploy init
|
|
109
|
+
dokploy init --output dokploy.yaml --force
|
|
110
|
+
|
|
51
111
|
dokploy apply -f dokploy.yaml
|
|
52
112
|
dokploy apply -f dokploy.yaml --dry-run
|
|
113
|
+
dokploy apply -f dokploy.yaml --state .dokploy-state.json
|
|
114
|
+
|
|
53
115
|
dokploy deploy frontend -f dokploy.yaml
|
|
54
116
|
dokploy status -f dokploy.yaml
|
|
117
|
+
|
|
55
118
|
dokploy destroy frontend -f dokploy.yaml
|
|
56
119
|
dokploy destroy -f dokploy.yaml
|
|
57
|
-
dokploy
|
|
120
|
+
dokploy destroy -f dokploy.yaml --delete-volumes
|
|
58
121
|
```
|
|
59
122
|
|
|
60
|
-
|
|
123
|
+
## Example Config
|
|
124
|
+
|
|
125
|
+
```yaml
|
|
126
|
+
host: https://your-dokploy.example.com
|
|
127
|
+
|
|
128
|
+
project:
|
|
129
|
+
name: My App
|
|
130
|
+
description: Deployed via dokploy
|
|
131
|
+
|
|
132
|
+
environment:
|
|
133
|
+
name: production
|
|
134
|
+
|
|
135
|
+
applications:
|
|
136
|
+
- name: frontend
|
|
137
|
+
source: github
|
|
138
|
+
github:
|
|
139
|
+
id: your-github-provider-id
|
|
140
|
+
owner: your-org
|
|
141
|
+
repository: your-repo
|
|
142
|
+
branch: main
|
|
143
|
+
buildPath: /
|
|
144
|
+
triggerType: push
|
|
145
|
+
build:
|
|
146
|
+
type: dockerfile
|
|
147
|
+
dockerfile: Dockerfile
|
|
148
|
+
contextPath: .
|
|
149
|
+
env:
|
|
150
|
+
NODE_ENV: production
|
|
151
|
+
VITE_BACKEND_URL: https://api.example.com
|
|
152
|
+
domains:
|
|
153
|
+
- host: app.example.com
|
|
154
|
+
port: 80
|
|
155
|
+
path: /
|
|
156
|
+
https: true
|
|
157
|
+
certificate: letsencrypt
|
|
158
|
+
deploy: true
|
|
159
|
+
|
|
160
|
+
databases:
|
|
161
|
+
- name: app-db
|
|
162
|
+
type: postgres
|
|
163
|
+
version: "16"
|
|
164
|
+
databaseName: app
|
|
165
|
+
databaseUser: app
|
|
166
|
+
password: change-me
|
|
167
|
+
deploy: true
|
|
168
|
+
```
|
|
61
169
|
|
|
62
|
-
|
|
170
|
+
More examples are in [`examples/`](examples/).
|
|
171
|
+
|
|
172
|
+
## Config Notes
|
|
173
|
+
|
|
174
|
+
- `host` can be the Dokploy root URL or `/api` URL.
|
|
175
|
+
- `environment` is optional. If omitted, the CLI uses the first environment returned by Dokploy for the project.
|
|
176
|
+
- `applications[].deploy: true` triggers a deploy after configuration.
|
|
177
|
+
- `buildArgs`, `buildSecrets`, and `createEnvFile` are supported for applications.
|
|
178
|
+
- Database creation requires a password because the Dokploy API requires one.
|
|
179
|
+
- State is written next to the config as `dokploy-state.json` unless `stateFile` or `--state` is provided.
|
|
63
180
|
|
|
64
|
-
|
|
181
|
+
## Project Inspection
|
|
182
|
+
|
|
183
|
+
Human-readable output:
|
|
65
184
|
|
|
66
185
|
```bash
|
|
67
|
-
|
|
186
|
+
dokploy projects --host https://your-dokploy.example.com
|
|
68
187
|
```
|
|
69
188
|
|
|
70
|
-
|
|
189
|
+
Short table only:
|
|
71
190
|
|
|
72
|
-
|
|
191
|
+
```bash
|
|
192
|
+
dokploy projects --summary --host https://your-dokploy.example.com
|
|
193
|
+
```
|
|
194
|
+
|
|
195
|
+
Raw JSON for scripts:
|
|
196
|
+
|
|
197
|
+
```bash
|
|
198
|
+
dokploy projects --json --host https://your-dokploy.example.com
|
|
199
|
+
```
|
|
200
|
+
|
|
201
|
+
## Troubleshooting
|
|
202
|
+
|
|
203
|
+
`zsh: command not found: dokploy`
|
|
204
|
+
|
|
205
|
+
You probably installed the package locally. Use:
|
|
206
|
+
|
|
207
|
+
```bash
|
|
208
|
+
npx dokploy --help
|
|
209
|
+
```
|
|
210
|
+
|
|
211
|
+
or install globally:
|
|
212
|
+
|
|
213
|
+
```bash
|
|
214
|
+
npm install -g @lishugupta652/dokploy
|
|
215
|
+
```
|
|
216
|
+
|
|
217
|
+
`Dokploy API /project.all failed with HTTP 404` and the response is HTML
|
|
218
|
+
|
|
219
|
+
The request hit the Dokploy web UI instead of the API. Use a recent package version and pass either:
|
|
220
|
+
|
|
221
|
+
```bash
|
|
222
|
+
dokploy projects --host https://your-dokploy.example.com
|
|
223
|
+
dokploy projects --host https://your-dokploy.example.com/api
|
|
224
|
+
```
|
|
225
|
+
|
|
226
|
+
`DOKPLOY_API_KEY is required`
|
|
227
|
+
|
|
228
|
+
Set the API key before running commands:
|
|
229
|
+
|
|
230
|
+
```bash
|
|
231
|
+
export DOKPLOY_API_KEY=your-api-key
|
|
232
|
+
```
|
|
233
|
+
|
|
234
|
+
## Development
|
|
235
|
+
|
|
236
|
+
```bash
|
|
237
|
+
npm install
|
|
238
|
+
npm run check
|
|
239
|
+
npm run build
|
|
240
|
+
npm run dev -- projects --host https://your-dokploy.example.com --summary
|
|
241
|
+
```
|
|
242
|
+
|
|
243
|
+
Using pnpm is fine if you switch the lockfile:
|
|
244
|
+
|
|
245
|
+
```bash
|
|
246
|
+
rm package-lock.json
|
|
247
|
+
pnpm install
|
|
248
|
+
pnpm run check
|
|
249
|
+
pnpm run build
|
|
250
|
+
```
|
|
251
|
+
|
|
252
|
+
## Publishing
|
|
253
|
+
|
|
254
|
+
The package name is `@lishugupta652/dokploy`; the binary is `dokploy`.
|
|
255
|
+
|
|
256
|
+
Safe dry-run:
|
|
73
257
|
|
|
74
258
|
```bash
|
|
75
259
|
./scripts/publish.sh npm
|
|
260
|
+
```
|
|
261
|
+
|
|
262
|
+
Publish:
|
|
263
|
+
|
|
264
|
+
```bash
|
|
76
265
|
./scripts/publish.sh npm --publish
|
|
266
|
+
```
|
|
267
|
+
|
|
268
|
+
If the current package version is already on npm, the publish script bumps `patch` automatically before publishing. Override the bump when needed:
|
|
269
|
+
|
|
270
|
+
```bash
|
|
271
|
+
./scripts/publish.sh npm --publish --bump patch
|
|
272
|
+
./scripts/publish.sh npm --publish --bump minor
|
|
273
|
+
./scripts/publish.sh npm --publish --bump major
|
|
274
|
+
./scripts/publish.sh npm --publish --bump none
|
|
275
|
+
```
|
|
276
|
+
|
|
277
|
+
pnpm flow:
|
|
278
|
+
|
|
279
|
+
```bash
|
|
77
280
|
./scripts/publish.sh pnpm
|
|
78
281
|
./scripts/publish.sh pnpm --publish
|
|
79
282
|
```
|
|
80
283
|
|
|
81
|
-
|
|
284
|
+
Publishing generates `CHANGELOG.md` from git commits since the latest tag. Conventional Commit messages are grouped into sections such as Features, Fixes, Breaking Changes, and Chores.
|
|
82
285
|
|
|
83
|
-
|
|
286
|
+
Direct `npm publish --access public` is also protected by `prepublishOnly`: it checks whether the current version already exists on npm and bumps `patch` when needed before building and generating the changelog.
|
|
84
287
|
|
|
85
|
-
## Commit
|
|
288
|
+
## Commit Messages And Versioning
|
|
86
289
|
|
|
87
|
-
Install
|
|
290
|
+
Install hooks:
|
|
88
291
|
|
|
89
292
|
```bash
|
|
90
293
|
npm run hooks:install
|
|
@@ -101,9 +304,3 @@ docs: update usage # no version bump
|
|
|
101
304
|
```
|
|
102
305
|
|
|
103
306
|
Use `SKIP_DOKPLOY_VERSION_BUMP=1` to keep commit validation but skip version changes. Use `SKIP_DOKPLOY_COMMIT_CHECK=1` only when you intentionally need to bypass the hook.
|
|
104
|
-
|
|
105
|
-
## Notes
|
|
106
|
-
|
|
107
|
-
- `apply` is idempotent by name within the selected environment where Dokploy exposes search endpoints.
|
|
108
|
-
- Applications are configured in Dokploy's required order: create, source provider, build type, environment, domains, deploy.
|
|
109
|
-
- Database creation requires a password because the Dokploy API requires one on create.
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@lishugupta652/dokploy",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.6",
|
|
4
4
|
"description": "A YAML-driven CLI for applying Dokploy projects through the Dokploy API.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"bin": {
|
|
@@ -22,7 +22,8 @@
|
|
|
22
22
|
"commit-msg": "node scripts/commit-msg.mjs",
|
|
23
23
|
"hooks:install": "node scripts/install-git-hooks.mjs",
|
|
24
24
|
"prepack": "npm run build",
|
|
25
|
-
"prepublishOnly": "npm run check && npm run build && npm run changelog",
|
|
25
|
+
"prepublishOnly": "npm run version:publish && npm run check && npm run build && npm run changelog",
|
|
26
|
+
"version:publish": "node scripts/ensure-publish-version.mjs",
|
|
26
27
|
"version:commit": "node scripts/bump-version-on-commit.mjs"
|
|
27
28
|
},
|
|
28
29
|
"publishConfig": {
|
|
@@ -0,0 +1,162 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
import { execFileSync } from "node:child_process";
|
|
3
|
+
import { existsSync, readFileSync, writeFileSync } from "node:fs";
|
|
4
|
+
import path from "node:path";
|
|
5
|
+
import { fileURLToPath } from "node:url";
|
|
6
|
+
|
|
7
|
+
const packageDir = path.resolve(path.dirname(fileURLToPath(import.meta.url)), "..");
|
|
8
|
+
const packageJsonPath = path.join(packageDir, "package.json");
|
|
9
|
+
const packageLockPath = path.join(packageDir, "package-lock.json");
|
|
10
|
+
const options = parseArgs(process.argv.slice(2));
|
|
11
|
+
|
|
12
|
+
const packageJson = readJson(packageJsonPath);
|
|
13
|
+
const packageName = stringValue(packageJson.name, "");
|
|
14
|
+
let version = stringValue(packageJson.version, "");
|
|
15
|
+
|
|
16
|
+
if (!packageName || !version) {
|
|
17
|
+
throw new Error("package.json must contain name and version.");
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
let attempts = 0;
|
|
21
|
+
while (isVersionPublished(options.packageManager, packageName, version)) {
|
|
22
|
+
if (options.bump === "none") {
|
|
23
|
+
console.error(`${packageName}@${version} is already published.`);
|
|
24
|
+
console.error("Pass --bump patch|minor|major or update package.json before publishing.");
|
|
25
|
+
process.exit(1);
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
const nextVersion = bumpVersion(version, options.bump);
|
|
29
|
+
console.log(`${packageName}@${version} is already published. Bumping ${options.bump}: ${nextVersion}`);
|
|
30
|
+
version = nextVersion;
|
|
31
|
+
attempts += 1;
|
|
32
|
+
|
|
33
|
+
if (attempts > 20) {
|
|
34
|
+
throw new Error("Stopped after 20 version bump attempts.");
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
if (version === packageJson.version) {
|
|
39
|
+
console.log(`${packageName}@${version} is not published yet.`);
|
|
40
|
+
process.exit(0);
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
if (options.dryRun) {
|
|
44
|
+
console.log(`Dry run: would update ${packageName} to ${version}.`);
|
|
45
|
+
process.exit(0);
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
packageJson.version = version;
|
|
49
|
+
writeJson(packageJsonPath, packageJson);
|
|
50
|
+
|
|
51
|
+
if (existsSync(packageLockPath)) {
|
|
52
|
+
const packageLock = readJson(packageLockPath);
|
|
53
|
+
packageLock.name = packageJson.name;
|
|
54
|
+
packageLock.version = version;
|
|
55
|
+
if (packageLock.packages?.[""]) {
|
|
56
|
+
packageLock.packages[""].name = packageJson.name;
|
|
57
|
+
packageLock.packages[""].version = version;
|
|
58
|
+
packageLock.packages[""].bin = packageJson.bin;
|
|
59
|
+
}
|
|
60
|
+
writeJson(packageLockPath, packageLock);
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
console.log(`Updated package version to ${packageName}@${version}.`);
|
|
64
|
+
|
|
65
|
+
function parseArgs(args) {
|
|
66
|
+
const parsed = {
|
|
67
|
+
bump: "patch",
|
|
68
|
+
packageManager: "npm",
|
|
69
|
+
dryRun: false,
|
|
70
|
+
};
|
|
71
|
+
|
|
72
|
+
for (let index = 0; index < args.length; index += 1) {
|
|
73
|
+
const arg = args[index];
|
|
74
|
+
switch (arg) {
|
|
75
|
+
case "--bump":
|
|
76
|
+
parsed.bump = stringArg(args, index);
|
|
77
|
+
index += 1;
|
|
78
|
+
break;
|
|
79
|
+
case "--package-manager":
|
|
80
|
+
parsed.packageManager = stringArg(args, index);
|
|
81
|
+
index += 1;
|
|
82
|
+
break;
|
|
83
|
+
case "--dry-run":
|
|
84
|
+
parsed.dryRun = true;
|
|
85
|
+
break;
|
|
86
|
+
default:
|
|
87
|
+
throw new Error(`Unknown argument: ${arg}`);
|
|
88
|
+
}
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
if (!["patch", "minor", "major", "none"].includes(parsed.bump)) {
|
|
92
|
+
throw new Error("--bump must be patch, minor, major, or none.");
|
|
93
|
+
}
|
|
94
|
+
if (!["npm", "pnpm"].includes(parsed.packageManager)) {
|
|
95
|
+
throw new Error("--package-manager must be npm or pnpm.");
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
return parsed;
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
function stringArg(args, index) {
|
|
102
|
+
const value = args[index + 1];
|
|
103
|
+
if (!value) {
|
|
104
|
+
throw new Error(`Missing value for ${args[index]}.`);
|
|
105
|
+
}
|
|
106
|
+
return value;
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
function isVersionPublished(packageManager, packageName, version) {
|
|
110
|
+
try {
|
|
111
|
+
const output = execFileSync(
|
|
112
|
+
packageManager,
|
|
113
|
+
["view", `${packageName}@${version}`, "version", "--json"],
|
|
114
|
+
{
|
|
115
|
+
encoding: "utf8",
|
|
116
|
+
stdio: ["ignore", "pipe", "pipe"],
|
|
117
|
+
},
|
|
118
|
+
).trim();
|
|
119
|
+
|
|
120
|
+
return output.length > 0 && output !== "null";
|
|
121
|
+
} catch (error) {
|
|
122
|
+
const stderr = String(error.stderr ?? "");
|
|
123
|
+
if (stderr.includes("E404") || stderr.includes("404 Not Found")) {
|
|
124
|
+
return false;
|
|
125
|
+
}
|
|
126
|
+
throw error;
|
|
127
|
+
}
|
|
128
|
+
}
|
|
129
|
+
|
|
130
|
+
function bumpVersion(version, bump) {
|
|
131
|
+
const match = version.match(/^(\d+)\.(\d+)\.(\d+)(-.+)?$/);
|
|
132
|
+
if (!match) {
|
|
133
|
+
throw new Error(`Unsupported semver version: ${version}`);
|
|
134
|
+
}
|
|
135
|
+
|
|
136
|
+
const major = Number(match[1]);
|
|
137
|
+
const minor = Number(match[2]);
|
|
138
|
+
const patch = Number(match[3]);
|
|
139
|
+
|
|
140
|
+
switch (bump) {
|
|
141
|
+
case "major":
|
|
142
|
+
return `${major + 1}.0.0`;
|
|
143
|
+
case "minor":
|
|
144
|
+
return `${major}.${minor + 1}.0`;
|
|
145
|
+
case "patch":
|
|
146
|
+
return `${major}.${minor}.${patch + 1}`;
|
|
147
|
+
default:
|
|
148
|
+
throw new Error(`Unsupported bump type: ${bump}`);
|
|
149
|
+
}
|
|
150
|
+
}
|
|
151
|
+
|
|
152
|
+
function readJson(filePath) {
|
|
153
|
+
return JSON.parse(readFileSync(filePath, "utf8"));
|
|
154
|
+
}
|
|
155
|
+
|
|
156
|
+
function writeJson(filePath, value) {
|
|
157
|
+
writeFileSync(filePath, `${JSON.stringify(value, null, 2)}\n`);
|
|
158
|
+
}
|
|
159
|
+
|
|
160
|
+
function stringValue(value, fallback) {
|
|
161
|
+
return typeof value === "string" ? value : fallback;
|
|
162
|
+
}
|
package/scripts/publish.sh
CHANGED
|
@@ -4,20 +4,23 @@ set -eu
|
|
|
4
4
|
PACKAGE_MANAGER="npm"
|
|
5
5
|
PUBLISH="0"
|
|
6
6
|
ACCESS="public"
|
|
7
|
+
BUMP="patch"
|
|
7
8
|
|
|
8
9
|
usage() {
|
|
9
10
|
cat <<'EOF'
|
|
10
11
|
Usage:
|
|
11
|
-
./scripts/publish.sh [npm|pnpm] [--publish] [--access public|restricted]
|
|
12
|
+
./scripts/publish.sh [npm|pnpm] [--publish] [--access public|restricted] [--bump patch|minor|major|none]
|
|
12
13
|
|
|
13
14
|
Examples:
|
|
14
15
|
./scripts/publish.sh npm
|
|
15
16
|
./scripts/publish.sh npm --publish
|
|
17
|
+
./scripts/publish.sh npm --publish --bump minor
|
|
16
18
|
./scripts/publish.sh pnpm
|
|
17
19
|
./scripts/publish.sh pnpm --publish
|
|
18
20
|
|
|
19
21
|
Default mode is safe: it runs checks and pack dry-run only.
|
|
20
22
|
Pass --publish to publish @lishugupta652/dokploy to npm.
|
|
23
|
+
In publish mode, if the current version already exists on npm, the script bumps patch by default.
|
|
21
24
|
EOF
|
|
22
25
|
}
|
|
23
26
|
|
|
@@ -43,6 +46,22 @@ while [ "$#" -gt 0 ]; do
|
|
|
43
46
|
ACCESS="$2"
|
|
44
47
|
shift 2
|
|
45
48
|
;;
|
|
49
|
+
--bump)
|
|
50
|
+
if [ "$#" -lt 2 ]; then
|
|
51
|
+
echo "Missing value for --bump" >&2
|
|
52
|
+
exit 1
|
|
53
|
+
fi
|
|
54
|
+
case "$2" in
|
|
55
|
+
patch|minor|major|none)
|
|
56
|
+
BUMP="$2"
|
|
57
|
+
;;
|
|
58
|
+
*)
|
|
59
|
+
echo "--bump must be patch, minor, major, or none" >&2
|
|
60
|
+
exit 1
|
|
61
|
+
;;
|
|
62
|
+
esac
|
|
63
|
+
shift 2
|
|
64
|
+
;;
|
|
46
65
|
-h|--help)
|
|
47
66
|
usage
|
|
48
67
|
exit 0
|
|
@@ -79,6 +98,7 @@ fi
|
|
|
79
98
|
echo "Package manager: $PACKAGE_MANAGER"
|
|
80
99
|
echo "Publish mode: $PUBLISH"
|
|
81
100
|
echo "Access: $ACCESS"
|
|
101
|
+
echo "Version bump: $BUMP"
|
|
82
102
|
echo ""
|
|
83
103
|
|
|
84
104
|
if [ "$PUBLISH" = "1" ]; then
|
|
@@ -88,6 +108,10 @@ if [ "$PUBLISH" = "1" ]; then
|
|
|
88
108
|
fi
|
|
89
109
|
echo "Logged in as: $("$PACKAGE_MANAGER" whoami)"
|
|
90
110
|
echo ""
|
|
111
|
+
|
|
112
|
+
echo "Checking npm version availability..."
|
|
113
|
+
node scripts/ensure-publish-version.mjs --package-manager "$PACKAGE_MANAGER" --bump "$BUMP"
|
|
114
|
+
echo ""
|
|
91
115
|
fi
|
|
92
116
|
|
|
93
117
|
echo "Checking package..."
|