@lishugupta652/dokploy 0.1.4 → 0.1.5

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.
@@ -0,0 +1,9 @@
1
+ #!/bin/sh
2
+ set -e
3
+
4
+ PACKAGE_DIR="dokploy-deploy-automation"
5
+ if [ ! -f "$PACKAGE_DIR/scripts/commit-msg.mjs" ]; then
6
+ PACKAGE_DIR="."
7
+ fi
8
+
9
+ node "$PACKAGE_DIR/scripts/commit-msg.mjs" "$1"
@@ -1,10 +1,5 @@
1
1
  #!/bin/sh
2
2
  set -e
3
3
 
4
- PACKAGE_DIR="dokploy-deploy-automation"
5
- if [ ! -f "$PACKAGE_DIR/scripts/bump-version-on-commit.mjs" ]; then
6
- PACKAGE_DIR="."
7
- fi
8
-
9
- node "$PACKAGE_DIR/scripts/bump-version-on-commit.mjs"
10
- git add "$PACKAGE_DIR/package.json" "$PACKAGE_DIR/package-lock.json"
4
+ # Commit message validation and semver bumping happen in commit-msg.
5
+ exit 0
package/CHANGELOG.md ADDED
@@ -0,0 +1,28 @@
1
+ # Changelog
2
+
3
+ ## 0.1.5 - 2026-04-13
4
+
5
+ _Initial changelog generated from repository history._
6
+
7
+ ### Fixes
8
+
9
+ - scripts (2930c10)
10
+
11
+ ### Other Changes
12
+
13
+ - add script for deployment (c511505)
14
+ - first commit (3f5e457)
15
+
16
+ ## 0.1.4 - 2026-04-13
17
+
18
+ _Initial changelog generated from repository history._
19
+
20
+ ### Fixes
21
+
22
+ - scripts (2930c10)
23
+
24
+ ### Other Changes
25
+
26
+ - add script for deployment (c511505)
27
+ - first commit (3f5e457)
28
+
package/README.md CHANGED
@@ -80,6 +80,8 @@ Or use the helper script:
80
80
 
81
81
  The script defaults to dry-run mode and publishes only when `--publish` is passed.
82
82
 
83
+ Publishing also 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.
84
+
83
85
  ## Commit Version Hook
84
86
 
85
87
  Install the repo hook once:
@@ -88,7 +90,17 @@ Install the repo hook once:
88
90
  npm run hooks:install
89
91
  ```
90
92
 
91
- The pre-commit hook bumps the package patch version and stages `package.json` plus `package-lock.json`. Set `SKIP_DOKPLOY_VERSION_BUMP=1` to skip it for a commit.
93
+ The `commit-msg` hook enforces Conventional Commits and bumps `package.json` plus `package-lock.json` from the commit message:
94
+
95
+ ```text
96
+ feat: add project listing # minor
97
+ fix(projects): normalize host # patch
98
+ perf: improve status lookup # patch
99
+ feat!: change config schema # major
100
+ docs: update usage # no version bump
101
+ ```
102
+
103
+ 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.
92
104
 
93
105
  ## Notes
94
106
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lishugupta652/dokploy",
3
- "version": "0.1.4",
3
+ "version": "0.1.5",
4
4
  "description": "A YAML-driven CLI for applying Dokploy projects through the Dokploy API.",
5
5
  "type": "module",
6
6
  "bin": {
@@ -11,15 +11,18 @@
11
11
  "examples",
12
12
  "scripts",
13
13
  ".githooks",
14
+ "CHANGELOG.md",
14
15
  "README.md"
15
16
  ],
16
17
  "scripts": {
17
18
  "build": "tsc -p tsconfig.json",
19
+ "changelog": "node scripts/generate-changelog.mjs",
18
20
  "check": "tsc -p tsconfig.json --noEmit",
19
21
  "dev": "tsx src/index.ts",
22
+ "commit-msg": "node scripts/commit-msg.mjs",
20
23
  "hooks:install": "node scripts/install-git-hooks.mjs",
21
24
  "prepack": "npm run build",
22
- "prepublishOnly": "npm run check && npm run build",
25
+ "prepublishOnly": "npm run check && npm run build && npm run changelog",
23
26
  "version:commit": "node scripts/bump-version-on-commit.mjs"
24
27
  },
25
28
  "publishConfig": {
@@ -0,0 +1,185 @@
1
+ #!/usr/bin/env node
2
+ import { execFileSync } from "node:child_process";
3
+ import { readFileSync, writeFileSync } from "node:fs";
4
+ import path from "node:path";
5
+ import { fileURLToPath } from "node:url";
6
+
7
+ const allowedTypes = new Set([
8
+ "feat",
9
+ "fix",
10
+ "perf",
11
+ "refactor",
12
+ "docs",
13
+ "test",
14
+ "build",
15
+ "ci",
16
+ "chore",
17
+ "style",
18
+ "revert",
19
+ ]);
20
+
21
+ const bumpByType = new Map([
22
+ ["feat", "minor"],
23
+ ["fix", "patch"],
24
+ ["perf", "patch"],
25
+ ]);
26
+
27
+ const messagePath = process.argv[2];
28
+ if (!messagePath) {
29
+ console.error("Missing commit message file path.");
30
+ process.exit(1);
31
+ }
32
+
33
+ const message = readFileSync(messagePath, "utf8");
34
+ const header = firstCommitMessageLine(message);
35
+
36
+ if (!header) {
37
+ fail("Commit message is empty.");
38
+ }
39
+
40
+ if (process.env.SKIP_DOKPLOY_COMMIT_CHECK === "1") {
41
+ process.exit(0);
42
+ }
43
+
44
+ if (isGeneratedCommit(header)) {
45
+ process.exit(0);
46
+ }
47
+
48
+ const parsed = parseConventionalCommit(header);
49
+ if (!parsed) {
50
+ fail(`Invalid commit message: ${header}`);
51
+ }
52
+
53
+ if (!allowedTypes.has(parsed.type)) {
54
+ fail(`Unsupported commit type "${parsed.type}".`);
55
+ }
56
+
57
+ if (parsed.subject.trim().length === 0) {
58
+ fail("Commit subject cannot be empty.");
59
+ }
60
+
61
+ const bump = resolveBump(parsed, message);
62
+ if (!bump) {
63
+ console.log(`Commit type "${parsed.type}" does not change the package version.`);
64
+ process.exit(0);
65
+ }
66
+
67
+ if (process.env.SKIP_DOKPLOY_VERSION_BUMP === "1") {
68
+ console.log(`Skipping ${bump} version bump because SKIP_DOKPLOY_VERSION_BUMP=1.`);
69
+ process.exit(0);
70
+ }
71
+
72
+ const packageDir = path.resolve(path.dirname(fileURLToPath(import.meta.url)), "..");
73
+ const packageJsonPath = path.join(packageDir, "package.json");
74
+ const packageLockPath = path.join(packageDir, "package-lock.json");
75
+
76
+ const packageJson = readJson(packageJsonPath);
77
+ const nextVersion = bumpVersion(packageJson.version, bump);
78
+
79
+ if (process.env.DOKPLOY_VERSION_DRY_RUN === "1") {
80
+ console.log(`${parsed.type} commit will create ${bump} version: ${packageJson.version} -> ${nextVersion}`);
81
+ process.exit(0);
82
+ }
83
+
84
+ packageJson.version = nextVersion;
85
+ writeJson(packageJsonPath, packageJson);
86
+
87
+ const packageLock = readJson(packageLockPath);
88
+ packageLock.name = packageJson.name;
89
+ packageLock.version = nextVersion;
90
+ if (packageLock.packages?.[""]) {
91
+ packageLock.packages[""].name = packageJson.name;
92
+ packageLock.packages[""].version = nextVersion;
93
+ packageLock.packages[""].bin = packageJson.bin;
94
+ }
95
+ writeJson(packageLockPath, packageLock);
96
+
97
+ execFileSync("git", ["-C", packageDir, "add", packageJsonPath, packageLockPath], {
98
+ stdio: "inherit",
99
+ });
100
+
101
+ console.log(`${parsed.type} commit created ${bump} version: ${packageJson.name}@${nextVersion}`);
102
+
103
+ function firstCommitMessageLine(rawMessage) {
104
+ return rawMessage
105
+ .split(/\r?\n/)
106
+ .map((line) => line.trim())
107
+ .find((line) => line.length > 0 && !line.startsWith("#"));
108
+ }
109
+
110
+ function isGeneratedCommit(headerLine) {
111
+ return (
112
+ headerLine.startsWith("Merge ") ||
113
+ headerLine.startsWith("Revert ") ||
114
+ headerLine.startsWith("fixup!") ||
115
+ headerLine.startsWith("squash!")
116
+ );
117
+ }
118
+
119
+ function parseConventionalCommit(headerLine) {
120
+ const match = headerLine.match(/^([a-z]+)(\([a-z0-9._/-]+\))?(!)?: (.+)$/);
121
+ if (!match) return undefined;
122
+
123
+ return {
124
+ type: match[1],
125
+ breaking: Boolean(match[3]),
126
+ subject: match[4],
127
+ };
128
+ }
129
+
130
+ function resolveBump(parsedCommit, rawMessage) {
131
+ if (parsedCommit.breaking || /\nBREAKING[ -]CHANGE:/m.test(rawMessage)) {
132
+ return "major";
133
+ }
134
+ return bumpByType.get(parsedCommit.type);
135
+ }
136
+
137
+ function bumpVersion(version, bump) {
138
+ if (typeof version !== "string") {
139
+ throw new Error("package.json version must be a string");
140
+ }
141
+
142
+ const match = version.match(/^(\d+)\.(\d+)\.(\d+)(-.+)?$/);
143
+ if (!match) {
144
+ throw new Error(`Unsupported semver version: ${version}`);
145
+ }
146
+
147
+ const major = Number(match[1]);
148
+ const minor = Number(match[2]);
149
+ const patch = Number(match[3]);
150
+
151
+ switch (bump) {
152
+ case "major":
153
+ return `${major + 1}.0.0`;
154
+ case "minor":
155
+ return `${major}.${minor + 1}.0`;
156
+ case "patch":
157
+ return `${major}.${minor}.${patch + 1}`;
158
+ default:
159
+ throw new Error(`Unsupported bump type: ${bump}`);
160
+ }
161
+ }
162
+
163
+ function readJson(filePath) {
164
+ return JSON.parse(readFileSync(filePath, "utf8"));
165
+ }
166
+
167
+ function writeJson(filePath, value) {
168
+ writeFileSync(filePath, `${JSON.stringify(value, null, 2)}\n`);
169
+ }
170
+
171
+ function fail(messageText) {
172
+ console.error(messageText);
173
+ console.error("");
174
+ console.error("Use Conventional Commits:");
175
+ console.error(" feat: add project listing");
176
+ console.error(" fix(projects): normalize Dokploy host");
177
+ console.error(" feat!: change config schema");
178
+ console.error("");
179
+ console.error("Version bump rules:");
180
+ console.error(" feat or feat(scope) -> minor");
181
+ console.error(" fix/perf -> patch");
182
+ console.error(" ! or BREAKING CHANGE -> major");
183
+ console.error(" docs/chore/etc. -> no version bump");
184
+ process.exit(1);
185
+ }
@@ -0,0 +1,169 @@
1
+ #!/usr/bin/env node
2
+ import { execFileSync } from "node:child_process";
3
+ import { 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 changelogPath = path.join(packageDir, "CHANGELOG.md");
10
+ const args = new Set(process.argv.slice(2));
11
+ const dryRun = args.has("--dry-run");
12
+
13
+ const packageJson = readJson(packageJsonPath);
14
+ const version = stringValue(packageJson.version, "0.0.0");
15
+ const today = new Date().toISOString().slice(0, 10);
16
+ const lastTag = getLastTag();
17
+ const commits = getCommits(lastTag);
18
+ const section = renderVersionSection(version, today, lastTag, commits);
19
+
20
+ if (dryRun) {
21
+ console.log(section.trimEnd());
22
+ process.exit(0);
23
+ }
24
+
25
+ const currentChangelog = readChangelog();
26
+ const nextChangelog = upsertVersionSection(currentChangelog, version, section);
27
+ writeFileSync(changelogPath, nextChangelog, "utf8");
28
+
29
+ console.log(`Updated CHANGELOG.md for ${packageJson.name}@${version}`);
30
+
31
+ function getLastTag() {
32
+ try {
33
+ return execFileSync("git", ["-C", packageDir, "describe", "--tags", "--abbrev=0"], {
34
+ encoding: "utf8",
35
+ stdio: ["ignore", "pipe", "ignore"],
36
+ }).trim();
37
+ } catch {
38
+ return undefined;
39
+ }
40
+ }
41
+
42
+ function getCommits(tag) {
43
+ const range = tag ? [`${tag}..HEAD`] : [];
44
+ const output = execFileSync(
45
+ "git",
46
+ [
47
+ "-C",
48
+ packageDir,
49
+ "log",
50
+ "--date=short",
51
+ "--pretty=format:%H%x1f%ad%x1f%s%x1f%b%x1e",
52
+ ...range,
53
+ ],
54
+ { encoding: "utf8" },
55
+ );
56
+
57
+ return output
58
+ .split("\x1e")
59
+ .map((record) => record.trim())
60
+ .filter(Boolean)
61
+ .map(parseCommit);
62
+ }
63
+
64
+ function parseCommit(record) {
65
+ const [hash = "", date = "", subject = "", body = ""] = record.split("\x1f");
66
+ const conventional = subject.match(/^([a-z]+)(\([a-z0-9._/-]+\))?(!)?: (.+)$/);
67
+
68
+ if (!conventional) {
69
+ return {
70
+ hash,
71
+ date,
72
+ type: "other",
73
+ breaking: /\nBREAKING[ -]CHANGE:/m.test(body),
74
+ subject,
75
+ };
76
+ }
77
+
78
+ return {
79
+ hash,
80
+ date,
81
+ type: conventional[1],
82
+ breaking: Boolean(conventional[3]) || /\nBREAKING[ -]CHANGE:/m.test(body),
83
+ subject: conventional[4],
84
+ };
85
+ }
86
+
87
+ function renderVersionSection(nextVersion, date, tag, commits) {
88
+ const lines = [`## ${nextVersion} - ${date}`, ""];
89
+ lines.push(tag ? `_Changes since ${tag}._` : "_Initial changelog generated from repository history._");
90
+ lines.push("");
91
+
92
+ if (commits.length === 0) {
93
+ lines.push("- No commits found since the last tag.", "");
94
+ return `${lines.join("\n")}\n`;
95
+ }
96
+
97
+ const breaking = commits.filter((commit) => commit.breaking);
98
+ appendGroup(lines, "Breaking Changes", breaking);
99
+
100
+ const grouped = [
101
+ ["Features", ["feat"]],
102
+ ["Fixes", ["fix"]],
103
+ ["Performance", ["perf"]],
104
+ ["Refactoring", ["refactor"]],
105
+ ["Documentation", ["docs"]],
106
+ ["Tests", ["test"]],
107
+ ["Build", ["build"]],
108
+ ["CI", ["ci"]],
109
+ ["Chores", ["chore"]],
110
+ ["Styles", ["style"]],
111
+ ["Reverts", ["revert"]],
112
+ ["Other Changes", ["other"]],
113
+ ];
114
+
115
+ for (const [title, types] of grouped) {
116
+ appendGroup(
117
+ lines,
118
+ title,
119
+ commits.filter((commit) => types.includes(commit.type) && !commit.breaking),
120
+ );
121
+ }
122
+
123
+ return `${lines.join("\n").trimEnd()}\n\n`;
124
+ }
125
+
126
+ function appendGroup(lines, title, commits) {
127
+ if (commits.length === 0) return;
128
+
129
+ lines.push(`### ${title}`, "");
130
+ for (const commit of commits) {
131
+ lines.push(`- ${commit.subject} (${commit.hash.slice(0, 7)})`);
132
+ }
133
+ lines.push("");
134
+ }
135
+
136
+ function upsertVersionSection(currentChangelog, nextVersion, section) {
137
+ const header = "# Changelog\n\n";
138
+ const body = currentChangelog.startsWith("# Changelog\n")
139
+ ? currentChangelog.slice(header.length)
140
+ : currentChangelog.trimStart();
141
+ const versionHeader = `## ${nextVersion} - `;
142
+ const start = body.indexOf(versionHeader);
143
+
144
+ if (start === -1) {
145
+ return `${header}${section}${body.trimStart()}`;
146
+ }
147
+
148
+ const nextSectionStart = body.indexOf("\n## ", start + 1);
149
+ const before = body.slice(0, start);
150
+ const after = nextSectionStart === -1 ? "" : body.slice(nextSectionStart + 1);
151
+
152
+ return `${header}${before}${section}${after}`.replace(/\n{3,}/g, "\n\n");
153
+ }
154
+
155
+ function readChangelog() {
156
+ try {
157
+ return readFileSync(changelogPath, "utf8");
158
+ } catch {
159
+ return "# Changelog\n\n";
160
+ }
161
+ }
162
+
163
+ function readJson(filePath) {
164
+ return JSON.parse(readFileSync(filePath, "utf8"));
165
+ }
166
+
167
+ function stringValue(value, fallback) {
168
+ return typeof value === "string" ? value : fallback;
169
+ }
@@ -102,6 +102,15 @@ echo "CLI smoke test..."
102
102
  node dist/index.js --version
103
103
  node dist/index.js --help >/dev/null
104
104
 
105
+ echo ""
106
+ if [ "$PUBLISH" = "1" ]; then
107
+ echo "Generating changelog..."
108
+ "$PACKAGE_MANAGER" run changelog
109
+ else
110
+ echo "Changelog dry-run..."
111
+ "$PACKAGE_MANAGER" run changelog -- --dry-run
112
+ fi
113
+
105
114
  echo ""
106
115
  echo "Pack dry-run..."
107
116
  "$PACKAGE_MANAGER" pack --dry-run