Skip to content

Commit 3680c72

Browse files
authored
Merge pull request #2 from restfulhead/sub-packages
refactor: use sub-packages
2 parents eeb57bb + 4bc2d4a commit 3680c72

File tree

100 files changed

+3614
-5755
lines changed

Some content is hidden

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

100 files changed

+3614
-5755
lines changed

.autorc

+38
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
{
2+
"plugins": [
3+
"@restfulhead/auto-plugin-filter-by-workspace-path",
4+
"npm"
5+
],
6+
"labels": [
7+
{
8+
"name": "release-major",
9+
"changelogTitle": "💥 Major breaking Change",
10+
"releaseType": "major",
11+
"color": "#c5000b"
12+
},
13+
{
14+
"name": "release-minor",
15+
"changelogTitle": "🚀 Enhancement",
16+
"releaseType": "minor",
17+
"color": "#F9D0C4"
18+
},
19+
{
20+
"name": "release-patch",
21+
"changelogTitle": "🐛 Patch",
22+
"releaseType": "patch",
23+
"color": "#C2E0C6"
24+
},
25+
{
26+
"name": "release-internal",
27+
"changelogTitle": "🔩 Internal",
28+
"releaseType": "patch",
29+
"color": "#BFD4F2"
30+
},
31+
{
32+
"name": "release-docs",
33+
"changelogTitle": "📝 Documentation",
34+
"releaseType": "patch",
35+
"color": "#BFD4F2"
36+
}
37+
]
38+
}

.github/workflows/build.yml

+3-10
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,6 @@ jobs:
1919
steps:
2020
- uses: actions/checkout@v3
2121
with:
22-
fetch-depth: 0
2322
token: ${{ secrets.GH_TOKEN }}
2423

2524
- name: Setting up ${{ matrix.node-version }}
@@ -32,16 +31,10 @@ jobs:
3231
run: npm ci
3332

3433
- name: Build
35-
run: npm run build:prod
34+
run: npm run build -ws
3635

3736
- name: Lint
38-
run: npm run lint
37+
run: npm run lint -ws
3938

4039
- name: Test
41-
run: npm test
42-
43-
- name: Release preview
44-
run: |
45-
npx auto shipit --dry-run
46-
env:
47-
GITHUB_TOKEN: ${{ secrets.GH_TOKEN }}
40+
run: npm test -ws

.github/workflows/publish.yml

-38
This file was deleted.

.github/workflows/release.yml

+121
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,121 @@
1+
name: Release
2+
concurrency:
3+
group: ${{ github.ref }}
4+
cancel-in-progress: true
5+
6+
permissions:
7+
contents: write
8+
issues: write
9+
pull-requests: write
10+
11+
on:
12+
push:
13+
branches:
14+
- release
15+
16+
jobs:
17+
release:
18+
runs-on: ubuntu-latest
19+
timeout-minutes: 30
20+
defaults:
21+
run:
22+
shell: bash
23+
24+
steps:
25+
- uses: actions/checkout@v3
26+
with:
27+
fetch-depth: 0
28+
ref: ${{ inputs.git-ref }}
29+
30+
- name: Setup GIT
31+
run: |
32+
git config user.email "$GITHUB_ACTOR@users.noreply.github.com"
33+
git config user.name "$GITHUB_ACTOR"
34+
35+
- name: Setup Node.js
36+
uses: actions/setup-node@v3
37+
with:
38+
node-version: 18
39+
cache: "npm"
40+
cache-dependency-path: "package-lock.json"
41+
registry-url: 'https://registry.npmjs.org'
42+
43+
- name: Install dependencies
44+
env:
45+
CI: true
46+
run: |
47+
npm ci
48+
49+
- name: Get workspaces
50+
id: get-workspaces
51+
run: |
52+
echo "branch=${GITHUB_HEAD_REF:-${GITHUB_REF#refs/heads/}}" >> $GITHUB_OUTPUT
53+
echo "commit=${{ github.sha }}" >> $GITHUB_OUTPUT
54+
ws=$(npm ls --omit=dev --depth 1 -json | jq -r '.dependencies[].resolved[11:]')
55+
echo 'ws<<EOF' >> $GITHUB_OUTPUT
56+
echo $ws >> $GITHUB_OUTPUT
57+
echo 'EOF' >> $GITHUB_OUTPUT
58+
59+
- name: Build workspaces
60+
env:
61+
CI: true
62+
run: |
63+
npm run build -ws
64+
65+
- name: Release workspaces
66+
if: steps.get-workspaces.outputs.ws != ''
67+
env:
68+
CI: true
69+
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
70+
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
71+
run: |
72+
topdir=$(pwd)
73+
for workspace in ${{ steps.get-workspaces.outputs.ws }}; do
74+
if [ "$workspace" = "packages/azure-functions-openapi-validator-example" ]; then
75+
echo "Skipping release for $workspace"
76+
continue
77+
fi
78+
79+
echo "Potentially going to version and release $workspace"
80+
cd $workspace
81+
mkdir .git
82+
83+
PCKG_NAME=`node -pe "require('./package.json').name"`
84+
CUR_VERSION_NO=`node -pe "require('./package.json').version"`
85+
86+
FROM_PARAM=""
87+
if [ "$CUR_VERSION_NO" != "0.0.0" ]; then
88+
FROM_PARAM="--from ${PCKG_NAME}_v${CUR_VERSION_NO}"
89+
fi
90+
91+
VERSION=`npx auto version $FROM_PARAM`
92+
if [ ! -z "$VERSION" ]; then
93+
echo "::notice title=✅ Detected $VERSION version change for $PCKG_NAME::Bumping version"
94+
npx auto changelog --base-branch ${{ steps.get-workspaces.outputs.branch }} $FROM_PARAM
95+
npm version $VERSION -m "chore: bump release version to %s [skip ci]"
96+
NEW_VERSION_NO=`node -pe "require('./package.json').version"`
97+
git tag -d v$NEW_VERSION_NO
98+
NEW_TAG=${PCKG_NAME}_v$NEW_VERSION_NO
99+
echo "Going to create a new release for $NEW_TAG"
100+
git add -A
101+
git commit -m "chore: release v$NEW_VERSION_NO [skip ci]"
102+
git tag -a $NEW_TAG -m "chore: tag v$NEW_VERSION_NO [skip ci]"
103+
git push "https://$GITHUB_ACTOR:$GITHUB_TOKEN@github.com/$GITHUB_REPOSITORY" HEAD:${{ steps.get-workspaces.outputs.branch }} --follow-tags
104+
npx auto release --use-version $NEW_TAG $FROM_PARAM --base-branch ${{ steps.get-workspaces.outputs.branch }}
105+
IS_PRIVATE=`node -pe "require('./package.json').private"`
106+
if [ "$IS_PRIVATE" != "true" ]; then
107+
npm publish ./dist
108+
echo "::notice title=🚀 ${PCKG_NAME} v$NEW_VERSION_NO::Package versioned and published"
109+
fi
110+
rm -rf .git
111+
else
112+
echo "::notice title=Versioning of $PCKG_NAME skipped::No relevant changes detected."
113+
fi
114+
115+
cd $topdir
116+
done
117+
118+
- if: ${{ always() }}
119+
name: Clean working directory
120+
run: |
121+
rm -r *

.gitignore

+1
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,7 @@ jspm_packages/
6868
dist
6969
dist-test
7070
out
71+
tsconfig.tsbuildinfo
7172

7273
# Azure Functions artifacts
7374
bin

.vscode/launch.json

+25-3
Original file line numberDiff line numberDiff line change
@@ -9,14 +9,36 @@
99
"preLaunchTask": "func: host start"
1010
},
1111
{
12-
"name": "Unit test current file",
12+
"name": "[ajv-openapi-request-response-validator] Unit test current file",
1313
"type": "node",
1414
"request": "launch",
15+
"cwd": "${workspaceFolder}/packages/ajv-openapi-request-response-validator",
1516
"program": "${workspaceFolder}/node_modules/jest/bin/jest",
16-
"args": ["${relativeFile}", "--config", "${workspaceFolder}/jest.config.js", "--testTimeout", "300000", "--no-cache", "--runInBand", "--detectOpenHandles"],
17+
"args": ["${relativeFile}", "--config", "./jest.debug.config.js", "--testTimeout", "300000", "--no-cache", "--runInBand", "--detectOpenHandles"],
1718
"internalConsoleOptions": "openOnSessionStart",
1819
"sourceMaps": true,
19-
"outFiles": ["${workspaceFolder}/dist/**/*.js"],
20+
"outFiles": ["./dist/**/*.js"],
21+
"outputCapture": "std",
22+
"smartStep": true,
23+
"skipFiles": [
24+
"<node_internals>/**",
25+
"node_modules/**"
26+
],
27+
"resolveSourceMapLocations": [
28+
"${workspaceFolder}/**",
29+
"!**/node_modules/**"
30+
]
31+
},
32+
{
33+
"name": "[azure-functions-openapi-validator] Unit test current file",
34+
"type": "node",
35+
"request": "launch",
36+
"cwd": "${workspaceFolder}/packages/azure-functions-openapi-validator",
37+
"program": "${workspaceFolder}/node_modules/jest/bin/jest",
38+
"args": ["${relativeFile}", "--config", "./jest.debug.config.js", "--testTimeout", "300000", "--no-cache", "--runInBand", "--detectOpenHandles"],
39+
"internalConsoleOptions": "openOnSessionStart",
40+
"sourceMaps": true,
41+
"outFiles": ["./dist/**/*.js"],
2042
"outputCapture": "std",
2143
"smartStep": true,
2244
"skipFiles": [

.vscode/settings.json

+3-3
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
{
2-
"azureFunctions.deploySubpath": "example",
2+
"azureFunctions.deploySubpath": "packages/ajv-openapi-request-response-validator",
33
"azureFunctions.postDeployTask": "npm install (functions)",
44
"azureFunctions.projectLanguage": "TypeScript",
55
"azureFunctions.projectRuntime": "~4",
66
"debug.internalConsoleOptions": "neverOpen",
77
"azureFunctions.projectLanguageModel": 4,
8-
"azureFunctions.projectSubpath": "example",
8+
"azureFunctions.projectSubpath": "packages/ajv-openapi-request-response-validator",
99
"azureFunctions.preDeployTask": "npm prune (functions)",
1010

1111
// Place your settings in this file to overwrite default and user settings.
@@ -27,7 +27,7 @@
2727
"[json]": {
2828
"editor.formatOnSave": true
2929
},
30-
"eslint.workingDirectories": ["example", "src", "test"],
30+
"eslint.workingDirectories": [{ "mode": "auto" }],
3131
"eslint.options": {
3232
"resolvePluginsRelativeTo": "."
3333
},

.vscode/tasks.json

+5-30
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
"isBackground": true,
1010
"dependsOn": "npm build (functions)",
1111
"options": {
12-
"cwd": "${workspaceFolder}/example"
12+
"cwd": "${workspaceFolder}/packages/azure-functions-openapi-validator-example"
1313
},
1414
"presentation": {
1515
"reveal": "always",
@@ -20,12 +20,9 @@
2020
{
2121
"type": "shell",
2222
"label": "npm build (functions)",
23-
"command": "npm run build",
23+
"command": "npm run build -ws",
2424
"dependsOn": "npm clean (functions)",
2525
"problemMatcher": "$tsc",
26-
"options": {
27-
"cwd": "${workspaceFolder}/example"
28-
},
2926
"presentation": {
3027
"reveal": "silent",
3128
"revealProblems": "onProblem",
@@ -34,11 +31,8 @@
3431
},
3532
{
3633
"type": "shell",
37-
"label": "npm install (functions)",
38-
"command": "npm install",
39-
"options": {
40-
"cwd": "${workspaceFolder}/example"
41-
},
34+
"label": "npm clean (functions)",
35+
"command": "npm run clean -ws",
4236
"presentation": {
4337
"reveal": "silent",
4438
"revealProblems": "onProblem",
@@ -48,26 +42,7 @@
4842
{
4943
"type": "shell",
5044
"label": "npm prune (functions)",
51-
"command": "npm prune --production",
52-
"dependsOn": "npm build (functions)",
53-
"problemMatcher": [],
54-
"options": {
55-
"cwd": "${workspaceFolder}/example"
56-
},
57-
"presentation": {
58-
"reveal": "silent",
59-
"revealProblems": "onProblem",
60-
"close": true
61-
}
62-
},
63-
{
64-
"type": "shell",
65-
"label": "npm clean (functions)",
66-
"command": "npm run clean",
67-
"dependsOn": "npm install (functions)",
68-
"options": {
69-
"cwd": "${workspaceFolder}/example"
70-
},
45+
"command": "npm prune --prodcution",
7146
"presentation": {
7247
"reveal": "silent",
7348
"revealProblems": "onProblem",

0 commit comments

Comments
 (0)