api-spec-generator 0.0.9-alpha
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/.gitattributes +2 -0
- package/.github/workflows/ci.yml +196 -0
- package/LICENSE +21 -0
- package/README.md +2 -0
- package/dist/index.d.ts +3 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +5 -0
- package/dist/index.js.map +1 -0
- package/package.json +24 -0
- package/src/index.ts +5 -0
- package/tsconfig.json +44 -0
package/.gitattributes
ADDED
|
@@ -0,0 +1,196 @@
|
|
|
1
|
+
# This is a basic workflow to help you get started with Actions
|
|
2
|
+
|
|
3
|
+
name: CI
|
|
4
|
+
|
|
5
|
+
# Controls when the workflow will run
|
|
6
|
+
on:
|
|
7
|
+
push:
|
|
8
|
+
branches: [ "main", "*" ]
|
|
9
|
+
release:
|
|
10
|
+
types: [published]
|
|
11
|
+
workflow_dispatch:
|
|
12
|
+
inputs:
|
|
13
|
+
bump:
|
|
14
|
+
description: 'Type of version bump: major, minor, or patch'
|
|
15
|
+
required: true
|
|
16
|
+
default: 'patch'
|
|
17
|
+
append_alpha:
|
|
18
|
+
description: 'Append -alpha to the new version (true/false)'
|
|
19
|
+
required: false
|
|
20
|
+
default: 'true'
|
|
21
|
+
|
|
22
|
+
jobs:
|
|
23
|
+
bump-version:
|
|
24
|
+
name: Bump version, tag and create release
|
|
25
|
+
runs-on: ubuntu-latest
|
|
26
|
+
permissions:
|
|
27
|
+
contents: write
|
|
28
|
+
steps:
|
|
29
|
+
- name: Checkout
|
|
30
|
+
uses: actions/checkout@v4
|
|
31
|
+
with:
|
|
32
|
+
fetch-depth: 0
|
|
33
|
+
|
|
34
|
+
- name: Setup Node.js
|
|
35
|
+
uses: actions/setup-node@v4
|
|
36
|
+
with:
|
|
37
|
+
node-version: '22'
|
|
38
|
+
|
|
39
|
+
- name: Compute next tag from git tags
|
|
40
|
+
id: bump
|
|
41
|
+
uses: actions/github-script@v7
|
|
42
|
+
with:
|
|
43
|
+
script: |
|
|
44
|
+
const { execSync } = require('child_process');
|
|
45
|
+
const fs = require('fs');
|
|
46
|
+
|
|
47
|
+
// Get environment variables with defaults
|
|
48
|
+
const bumpType = process.env.BUMP_TYPE || 'patch';
|
|
49
|
+
const appendAlpha = process.env.APPEND_ALPHA || 'true';
|
|
50
|
+
|
|
51
|
+
console.log('Bump type:', bumpType);
|
|
52
|
+
|
|
53
|
+
// Validate BUMP_TYPE
|
|
54
|
+
if (!['major', 'minor', 'patch'].includes(bumpType)) {
|
|
55
|
+
throw new Error(`Invalid bump type: ${bumpType}`);
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
// Fetch tags
|
|
59
|
+
execSync('git fetch --tags');
|
|
60
|
+
|
|
61
|
+
// Get latest tag
|
|
62
|
+
let latestTag = '';
|
|
63
|
+
try {
|
|
64
|
+
latestTag = execSync('git tag --list "v*" --sort=-v:refname | head -n1', { encoding: 'utf8' }).trim();
|
|
65
|
+
} catch (e) {
|
|
66
|
+
latestTag = '';
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
if (!latestTag) {
|
|
70
|
+
latestTag = 'v0.0.0';
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
console.log('Latest tag:', latestTag);
|
|
74
|
+
|
|
75
|
+
// Parse version
|
|
76
|
+
let ver = latestTag.substring(1); // Remove 'v' prefix
|
|
77
|
+
const baseVer = ver.split('-')[0]; // Strip prerelease (e.g. -alpha)
|
|
78
|
+
|
|
79
|
+
let [maj, min, pat] = baseVer.split('.').map(x => parseInt(x) || 0);
|
|
80
|
+
|
|
81
|
+
// Bump version
|
|
82
|
+
switch (bumpType) {
|
|
83
|
+
case 'major':
|
|
84
|
+
maj++; min = 0; pat = 0;
|
|
85
|
+
break;
|
|
86
|
+
case 'minor':
|
|
87
|
+
min++; pat = 0;
|
|
88
|
+
break;
|
|
89
|
+
case 'patch':
|
|
90
|
+
pat++;
|
|
91
|
+
break;
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
const newBase = `${maj}.${min}.${pat}`;
|
|
95
|
+
const newVer = appendAlpha === 'true' ? `${newBase}-alpha` : newBase;
|
|
96
|
+
|
|
97
|
+
console.log('New version:', newVer);
|
|
98
|
+
|
|
99
|
+
// Set output for next steps
|
|
100
|
+
core.setOutput('version', newVer);
|
|
101
|
+
env:
|
|
102
|
+
BUMP_TYPE: ${{ github.event.inputs.bump }}
|
|
103
|
+
APPEND_ALPHA: ${{ github.event.inputs.append_alpha }}
|
|
104
|
+
|
|
105
|
+
- name: Create and push tag
|
|
106
|
+
run: |
|
|
107
|
+
git config user.name "github-actions[bot]"
|
|
108
|
+
git config user.email "41898282+github-actions[bot]@users.noreply.github.com"
|
|
109
|
+
TAG=v${{ steps.bump.outputs.version }}
|
|
110
|
+
COMMIT_MSG=$(git log -1 --pretty=%B)
|
|
111
|
+
echo "Creating tag $TAG"
|
|
112
|
+
git tag -a "$TAG" -m "$COMMIT_MSG"
|
|
113
|
+
git push origin "$TAG"
|
|
114
|
+
|
|
115
|
+
- name: Create GitHub release
|
|
116
|
+
uses: actions/create-release@v1
|
|
117
|
+
with:
|
|
118
|
+
tag_name: v${{ steps.bump.outputs.version }}
|
|
119
|
+
release_name: v${{ steps.bump.outputs.version }}
|
|
120
|
+
body: "Release ${{ steps.bump.outputs.version }} (automated)"
|
|
121
|
+
env:
|
|
122
|
+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
|
123
|
+
publish:
|
|
124
|
+
runs-on: ubuntu-latest
|
|
125
|
+
permissions:
|
|
126
|
+
contents: read
|
|
127
|
+
steps:
|
|
128
|
+
- name: Checkout
|
|
129
|
+
uses: actions/checkout@v4
|
|
130
|
+
with:
|
|
131
|
+
fetch-depth: 0
|
|
132
|
+
|
|
133
|
+
- name: Get latest tag
|
|
134
|
+
uses: actions/github-script@v7
|
|
135
|
+
id: get-tag
|
|
136
|
+
with:
|
|
137
|
+
script: |
|
|
138
|
+
const { execSync } = require('child_process');
|
|
139
|
+
|
|
140
|
+
// Get the latest tag
|
|
141
|
+
let latestTag = '';
|
|
142
|
+
try {
|
|
143
|
+
latestTag = execSync('git describe --tags $(git rev-list --tags --max-count=1)', { encoding: 'utf8' }).trim();
|
|
144
|
+
} catch (e) {
|
|
145
|
+
console.log('No tags found');
|
|
146
|
+
latestTag = '';
|
|
147
|
+
}
|
|
148
|
+
|
|
149
|
+
console.log('Latest tag:', latestTag);
|
|
150
|
+
core.setOutput('tag', latestTag);
|
|
151
|
+
|
|
152
|
+
if (!latestTag) {
|
|
153
|
+
core.setFailed('No tag found');
|
|
154
|
+
}
|
|
155
|
+
|
|
156
|
+
- name: Setup Node.js
|
|
157
|
+
uses: actions/setup-node@v4
|
|
158
|
+
with:
|
|
159
|
+
node-version: '22'
|
|
160
|
+
registry-url: 'https://registry.npmjs.org'
|
|
161
|
+
|
|
162
|
+
- name: Install dependencies
|
|
163
|
+
run: npm ci
|
|
164
|
+
|
|
165
|
+
- name: Build
|
|
166
|
+
run: npm run build
|
|
167
|
+
|
|
168
|
+
- name: Add version to package.json
|
|
169
|
+
uses: actions/github-script@v7
|
|
170
|
+
with:
|
|
171
|
+
script: |
|
|
172
|
+
const fs = require('fs');
|
|
173
|
+
const path = require('path');
|
|
174
|
+
|
|
175
|
+
const tagName = '${{ steps.get-tag.outputs.tag }}';
|
|
176
|
+
console.log('Setting version from tag:', tagName);
|
|
177
|
+
|
|
178
|
+
// Remove 'v' prefix if present
|
|
179
|
+
const version = tagName.startsWith('v') ? tagName.slice(1) : tagName;
|
|
180
|
+
|
|
181
|
+
// Read package.json
|
|
182
|
+
const packageJsonPath = path.join(process.cwd(), 'package.json');
|
|
183
|
+
const packageJson = JSON.parse(fs.readFileSync(packageJsonPath, 'utf8'));
|
|
184
|
+
|
|
185
|
+
// Update version
|
|
186
|
+
packageJson.version = version;
|
|
187
|
+
|
|
188
|
+
// Write back
|
|
189
|
+
fs.writeFileSync(packageJsonPath, JSON.stringify(packageJson, null, 2) + '\n');
|
|
190
|
+
|
|
191
|
+
console.log('Updated package.json version to:', version);
|
|
192
|
+
|
|
193
|
+
- name: Publish to npm
|
|
194
|
+
run: npm publish
|
|
195
|
+
env:
|
|
196
|
+
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
|
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 thedesertfox2
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
ADDED
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,QAAA,MAAM,oBAAoB,YAEzB,CAAC;AAEF,eAAe,oBAAoB,CAAC"}
|
package/dist/index.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,MAAM,oBAAoB,GAAG,GAAG,EAAE;IAC9B,OAAO,CAAC,GAAG,CAAC,eAAe,CAAC,CAAC;AACjC,CAAC,CAAC;AAEF,eAAe,oBAAoB,CAAC"}
|
package/package.json
ADDED
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "api-spec-generator",
|
|
3
|
+
"description": "",
|
|
4
|
+
"main": "dist/index.js",
|
|
5
|
+
"type": "module",
|
|
6
|
+
"scripts": {
|
|
7
|
+
"build": "tsc",
|
|
8
|
+
"test": "echo \"Error: no test specified\" && exit 1"
|
|
9
|
+
},
|
|
10
|
+
"repository": {
|
|
11
|
+
"type": "git",
|
|
12
|
+
"url": "git+https://github.com/TheDevOpAl/aws-api-gateway-spec-file-generator.git"
|
|
13
|
+
},
|
|
14
|
+
"author": "",
|
|
15
|
+
"license": "ISC",
|
|
16
|
+
"bugs": {
|
|
17
|
+
"url": "https://github.com/TheDevOpAl/aws-api-gateway-spec-file-generator/issues"
|
|
18
|
+
},
|
|
19
|
+
"homepage": "https://github.com/TheDevOpAl/aws-api-gateway-spec-file-generator#readme",
|
|
20
|
+
"devDependencies": {
|
|
21
|
+
"typescript": "^5.9.3"
|
|
22
|
+
},
|
|
23
|
+
"version": "0.0.9-alpha"
|
|
24
|
+
}
|
package/src/index.ts
ADDED
package/tsconfig.json
ADDED
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
{
|
|
2
|
+
// Visit https://aka.ms/tsconfig to read more about this file
|
|
3
|
+
"compilerOptions": {
|
|
4
|
+
// File Layout
|
|
5
|
+
"rootDir": "./src",
|
|
6
|
+
"outDir": "./dist",
|
|
7
|
+
|
|
8
|
+
// Environment Settings
|
|
9
|
+
// See also https://aka.ms/tsconfig/module
|
|
10
|
+
"module": "nodenext",
|
|
11
|
+
"target": "esnext",
|
|
12
|
+
"types": [],
|
|
13
|
+
// For nodejs:
|
|
14
|
+
// "lib": ["esnext"],
|
|
15
|
+
// "types": ["node"],
|
|
16
|
+
// and npm install -D @types/node
|
|
17
|
+
|
|
18
|
+
// Other Outputs
|
|
19
|
+
"sourceMap": true,
|
|
20
|
+
"declaration": true,
|
|
21
|
+
"declarationMap": true,
|
|
22
|
+
|
|
23
|
+
// Stricter Typechecking Options
|
|
24
|
+
"noUncheckedIndexedAccess": true,
|
|
25
|
+
"exactOptionalPropertyTypes": true,
|
|
26
|
+
|
|
27
|
+
// Style Options
|
|
28
|
+
// "noImplicitReturns": true,
|
|
29
|
+
// "noImplicitOverride": true,
|
|
30
|
+
// "noUnusedLocals": true,
|
|
31
|
+
// "noUnusedParameters": true,
|
|
32
|
+
// "noFallthroughCasesInSwitch": true,
|
|
33
|
+
// "noPropertyAccessFromIndexSignature": true,
|
|
34
|
+
|
|
35
|
+
// Recommended Options
|
|
36
|
+
"strict": true,
|
|
37
|
+
"jsx": "react-jsx",
|
|
38
|
+
"verbatimModuleSyntax": true,
|
|
39
|
+
"isolatedModules": true,
|
|
40
|
+
"noUncheckedSideEffectImports": true,
|
|
41
|
+
"moduleDetection": "force",
|
|
42
|
+
"skipLibCheck": true,
|
|
43
|
+
}
|
|
44
|
+
}
|