Skip to content

Commit 7fe9b6b

Browse files
author
Manuel Lara
committed
Initial release v1.0.0
DevLink - Local package development and linking tool with namespace support Features: - Namespace isolation for different projects/contexts - Multi-version support - Automatic consumer updates with push command - Declarative configuration - File locking for concurrent operations - Embedded documentation (devlink docs)
0 parents  commit 7fe9b6b

76 files changed

Lines changed: 15230 additions & 0 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.github/workflows/ci.yml

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
name: CI
2+
3+
on:
4+
push:
5+
branches: [main]
6+
pull_request:
7+
branches: [main]
8+
9+
jobs:
10+
test:
11+
runs-on: ubuntu-latest
12+
strategy:
13+
matrix:
14+
node-version: [18, 20, 22]
15+
16+
steps:
17+
- uses: actions/checkout@v4
18+
19+
- name: Setup Node.js ${{ matrix.node-version }}
20+
uses: actions/setup-node@v4
21+
with:
22+
node-version: ${{ matrix.node-version }}
23+
cache: 'npm'
24+
25+
- name: Install dependencies
26+
run: npm ci
27+
28+
- name: Build
29+
run: npm run build
30+
31+
- name: Run tests
32+
run: npm test
33+
34+
- name: Run tests with coverage
35+
if: matrix.node-version == 20
36+
run: npm run test:coverage

.github/workflows/publish-npm.yml

Lines changed: 128 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,128 @@
1+
name: Publish to npm (Public)
2+
3+
on:
4+
push:
5+
tags:
6+
- 'v*-npm'
7+
8+
jobs:
9+
validate:
10+
runs-on: ubuntu-latest
11+
outputs:
12+
version: ${{ steps.check.outputs.version }}
13+
needs_bump: ${{ steps.check.outputs.needs_bump }}
14+
steps:
15+
- uses: actions/checkout@v4
16+
17+
- name: Setup Node.js
18+
uses: actions/setup-node@v4
19+
with:
20+
node-version: '20'
21+
22+
- name: Validate and compare versions
23+
id: check
24+
run: |
25+
# Install semver for proper semantic version comparison
26+
npm install -g semver
27+
28+
# Extract version from tag (remove 'v' prefix and '-npm' suffix)
29+
RAW_TAG="${GITHUB_REF_NAME#v}"
30+
TAG_VERSION="${RAW_TAG%-npm}"
31+
32+
# Validate tag is valid semver
33+
if ! semver "$TAG_VERSION" > /dev/null 2>&1; then
34+
echo "::error::Invalid semver tag: $TAG_VERSION"
35+
exit 1
36+
fi
37+
38+
# Extract version from package.json
39+
PKG_VERSION=$(node -p "require('./package.json').version")
40+
41+
echo "Tag version: $TAG_VERSION"
42+
echo "Package.json version: $PKG_VERSION"
43+
44+
# Compare versions using semver
45+
# semver returns the higher version, or empty if invalid
46+
COMPARISON=$(semver "$TAG_VERSION" "$PKG_VERSION" | tail -1)
47+
48+
if [ "$TAG_VERSION" = "$PKG_VERSION" ]; then
49+
echo "✅ Versions match exactly: $TAG_VERSION"
50+
echo "version=$TAG_VERSION" >> $GITHUB_OUTPUT
51+
echo "needs_bump=false" >> $GITHUB_OUTPUT
52+
elif [ "$COMPARISON" = "$TAG_VERSION" ]; then
53+
echo "✅ Tag version ($TAG_VERSION) is greater than package.json ($PKG_VERSION)"
54+
echo " Will set version to $TAG_VERSION for publish"
55+
echo "version=$TAG_VERSION" >> $GITHUB_OUTPUT
56+
echo "needs_bump=true" >> $GITHUB_OUTPUT
57+
else
58+
echo "::error::Tag version ($TAG_VERSION) is less than package.json version ($PKG_VERSION)"
59+
echo "::error::Cannot publish an older version. Current: $PKG_VERSION, Tag: $TAG_VERSION"
60+
exit 1
61+
fi
62+
63+
test:
64+
needs: validate
65+
runs-on: ubuntu-latest
66+
steps:
67+
- uses: actions/checkout@v4
68+
69+
- name: Setup Node.js
70+
uses: actions/setup-node@v4
71+
with:
72+
node-version: '20'
73+
cache: 'npm'
74+
75+
- name: Install dependencies
76+
run: npm ci
77+
78+
- name: Run tests
79+
run: npm test
80+
81+
publish:
82+
needs: [validate, test]
83+
runs-on: ubuntu-latest
84+
permissions:
85+
contents: read
86+
87+
steps:
88+
- uses: actions/checkout@v4
89+
90+
- name: Setup Node.js
91+
uses: actions/setup-node@v4
92+
with:
93+
node-version: '20'
94+
cache: 'npm'
95+
registry-url: 'https://registry.npmjs.org'
96+
97+
- name: Install dependencies
98+
run: npm ci
99+
100+
- name: Set version
101+
run: npm version ${{ needs.validate.outputs.version }} --no-git-tag-version --allow-same-version
102+
103+
- name: Remove publishConfig (use npm public registry)
104+
run: |
105+
node -e "
106+
const pkg = require('./package.json');
107+
delete pkg.publishConfig;
108+
require('fs').writeFileSync('package.json', JSON.stringify(pkg, null, 2));
109+
"
110+
111+
- name: Build
112+
run: npm run build
113+
114+
- name: Publish to npm
115+
run: npm publish --access public
116+
env:
117+
NODE_AUTH_TOKEN: ${{ secrets.NPM_REGISTRY_TOKEN }}
118+
119+
- name: Summary
120+
run: |
121+
echo "## 📦 Published @unlimitechcloud/devlink@${{ needs.validate.outputs.version }} to npm" >> $GITHUB_STEP_SUMMARY
122+
echo "" >> $GITHUB_STEP_SUMMARY
123+
echo "🌐 Public registry: https://www.npmjs.com/package/@unlimitechcloud/devlink" >> $GITHUB_STEP_SUMMARY
124+
echo "" >> $GITHUB_STEP_SUMMARY
125+
echo "Install with:" >> $GITHUB_STEP_SUMMARY
126+
echo "\`\`\`bash" >> $GITHUB_STEP_SUMMARY
127+
echo "npm install @unlimitechcloud/devlink@${{ needs.validate.outputs.version }}" >> $GITHUB_STEP_SUMMARY
128+
echo "\`\`\`" >> $GITHUB_STEP_SUMMARY

.github/workflows/publish.yml

Lines changed: 136 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,136 @@
1+
name: Publish to GitHub Packages
2+
3+
on:
4+
push:
5+
tags:
6+
- 'v*'
7+
- '!v*-npm'
8+
9+
jobs:
10+
validate:
11+
runs-on: ubuntu-latest
12+
outputs:
13+
version: ${{ steps.check.outputs.version }}
14+
needs_bump: ${{ steps.check.outputs.needs_bump }}
15+
steps:
16+
- uses: actions/checkout@v4
17+
18+
- name: Setup Node.js
19+
uses: actions/setup-node@v4
20+
with:
21+
node-version: '20'
22+
23+
- name: Validate and compare versions
24+
id: check
25+
run: |
26+
# Install semver for proper semantic version comparison
27+
npm install -g semver
28+
29+
# Extract version from tag (remove 'v' prefix)
30+
TAG_VERSION="${GITHUB_REF_NAME#v}"
31+
32+
# Validate tag is valid semver
33+
if ! semver "$TAG_VERSION" > /dev/null 2>&1; then
34+
echo "::error::Invalid semver tag: $TAG_VERSION"
35+
exit 1
36+
fi
37+
38+
# Extract version from package.json
39+
PKG_VERSION=$(node -p "require('./package.json').version")
40+
41+
echo "Tag version: $TAG_VERSION"
42+
echo "Package.json version: $PKG_VERSION"
43+
44+
# Compare versions using semver
45+
# semver returns the higher version, or empty if invalid
46+
COMPARISON=$(semver "$TAG_VERSION" "$PKG_VERSION" | tail -1)
47+
48+
if [ "$TAG_VERSION" = "$PKG_VERSION" ]; then
49+
echo "✅ Versions match exactly: $TAG_VERSION"
50+
echo "version=$TAG_VERSION" >> $GITHUB_OUTPUT
51+
echo "needs_bump=false" >> $GITHUB_OUTPUT
52+
elif [ "$COMPARISON" = "$TAG_VERSION" ]; then
53+
echo "✅ Tag version ($TAG_VERSION) is greater than package.json ($PKG_VERSION)"
54+
echo " Will auto-bump package.json to $TAG_VERSION"
55+
echo "version=$TAG_VERSION" >> $GITHUB_OUTPUT
56+
echo "needs_bump=true" >> $GITHUB_OUTPUT
57+
else
58+
echo "::error::Tag version ($TAG_VERSION) is less than package.json version ($PKG_VERSION)"
59+
echo "::error::Cannot publish an older version. Current: $PKG_VERSION, Tag: $TAG_VERSION"
60+
exit 1
61+
fi
62+
63+
test:
64+
needs: validate
65+
runs-on: ubuntu-latest
66+
steps:
67+
- uses: actions/checkout@v4
68+
69+
- name: Setup Node.js
70+
uses: actions/setup-node@v4
71+
with:
72+
node-version: '20'
73+
cache: 'npm'
74+
75+
- name: Install dependencies
76+
run: npm ci
77+
78+
- name: Run tests
79+
run: npm test
80+
81+
publish:
82+
needs: [validate, test]
83+
runs-on: ubuntu-latest
84+
permissions:
85+
contents: write
86+
packages: write
87+
88+
steps:
89+
- uses: actions/checkout@v4
90+
91+
- name: Setup Node.js
92+
uses: actions/setup-node@v4
93+
with:
94+
node-version: '20'
95+
cache: 'npm'
96+
registry-url: 'https://npm.pkg.github.com'
97+
scope: '@unlimitechcloud'
98+
99+
- name: Install dependencies
100+
run: npm ci
101+
102+
- name: Bump version in package.json
103+
if: needs.validate.outputs.needs_bump == 'true'
104+
run: |
105+
npm version ${{ needs.validate.outputs.version }} --no-git-tag-version
106+
echo "📝 Updated package.json to version ${{ needs.validate.outputs.version }}"
107+
108+
- name: Build
109+
run: npm run build
110+
111+
- name: Publish to GitHub Packages
112+
run: npm publish
113+
env:
114+
NODE_AUTH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
115+
116+
- name: Commit version bump
117+
if: needs.validate.outputs.needs_bump == 'true'
118+
run: |
119+
git config user.name "github-actions[bot]"
120+
git config user.email "github-actions[bot]@users.noreply.github.com"
121+
git add package.json package-lock.json
122+
git commit -m "chore: bump version to ${{ needs.validate.outputs.version }} [skip ci]"
123+
git push origin HEAD:master
124+
125+
- name: Summary
126+
run: |
127+
echo "## 📦 Published @unlimitechcloud/devlink@${{ needs.validate.outputs.version }}" >> $GITHUB_STEP_SUMMARY
128+
echo "" >> $GITHUB_STEP_SUMMARY
129+
if [ "${{ needs.validate.outputs.needs_bump }}" = "true" ]; then
130+
echo "ℹ️ Version was auto-bumped from package.json" >> $GITHUB_STEP_SUMMARY
131+
echo "" >> $GITHUB_STEP_SUMMARY
132+
fi
133+
echo "Install with:" >> $GITHUB_STEP_SUMMARY
134+
echo "\`\`\`bash" >> $GITHUB_STEP_SUMMARY
135+
echo "npm install @unlimitechcloud/devlink@${{ needs.validate.outputs.version }}" >> $GITHUB_STEP_SUMMARY
136+
echo "\`\`\`" >> $GITHUB_STEP_SUMMARY

.gitignore

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
node_modules/
2+
dist/
3+
!fixtures/**/dist/
4+
coverage/
5+
*.log
6+
.DS_Store

0 commit comments

Comments
 (0)