fetch-client-generator 1.0.1

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,83 @@
1
+ name: Publish to NPM
2
+
3
+ on:
4
+ push:
5
+ branches:
6
+ - main
7
+ workflow_dispatch:
8
+
9
+ jobs:
10
+ publish:
11
+ runs-on: ubuntu-latest
12
+
13
+ steps:
14
+ - name: Checkout code
15
+ uses: actions/checkout@v4
16
+ with:
17
+ fetch-depth: 0
18
+ token: ${{ secrets.GITHUB_TOKEN }}
19
+
20
+ - name: Setup Node.js
21
+ uses: actions/setup-node@v4
22
+ with:
23
+ node-version: '18'
24
+ registry-url: 'https://registry.npmjs.org'
25
+
26
+ - name: Install dependencies
27
+ run: npm ci
28
+
29
+ - name: Run tests
30
+ run: npm test
31
+
32
+ - name: Configure git
33
+ run: |
34
+ git config --local user.email "action@github.com"
35
+ git config --local user.name "GitHub Action"
36
+
37
+ - name: Bump version and create tag
38
+ id: version
39
+ run: |
40
+ # Get the current version
41
+ CURRENT_VERSION=$(node -p "require('./package.json').version")
42
+ echo "Current version: $CURRENT_VERSION"
43
+
44
+ # Determine version bump type based on commit messages
45
+ if git log --format=%B -n 1 | grep -q "BREAKING CHANGE\|!:"; then
46
+ BUMP_TYPE="major"
47
+ elif git log --format=%B -n 1 | grep -q "^feat"; then
48
+ BUMP_TYPE="minor"
49
+ else
50
+ BUMP_TYPE="patch"
51
+ fi
52
+
53
+ echo "Bump type: $BUMP_TYPE"
54
+
55
+ # Bump version
56
+ NEW_VERSION=$(npm version $BUMP_TYPE --no-git-tag-version)
57
+ echo "New version: $NEW_VERSION"
58
+
59
+ # Commit version bump
60
+ git add package.json
61
+ git commit -m "chore: bump version to $NEW_VERSION"
62
+
63
+ # Create and push tag
64
+ git tag $NEW_VERSION
65
+ git push origin main
66
+ git push origin $NEW_VERSION
67
+
68
+ echo "version=$NEW_VERSION" >> $GITHUB_OUTPUT
69
+
70
+ - name: Publish to NPM
71
+ run: npm publish
72
+ env:
73
+ NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
74
+
75
+ - name: Create GitHub Release
76
+ uses: actions/create-release@v1
77
+ env:
78
+ GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
79
+ with:
80
+ tag_name: ${{ steps.version.outputs.version }}
81
+ release_name: Release ${{ steps.version.outputs.version }}
82
+ draft: false
83
+ prerelease: false
package/bin/cli.js ADDED
@@ -0,0 +1,29 @@
1
+ #!/usr/bin/env node
2
+
3
+ import { program } from 'commander';
4
+ import { readFileSync } from 'fs';
5
+ import { fileURLToPath } from 'url';
6
+ import path from 'path';
7
+
8
+ const __filename = fileURLToPath(import.meta.url);
9
+ const __dirname = path.dirname(__filename);
10
+ const packageJson = JSON.parse(readFileSync(path.join(__dirname, '../package.json'), 'utf8'));
11
+
12
+ program
13
+ .name('fetch-client-generator')
14
+ .description('A tool for generating fetch-based HTTP client code')
15
+ .version(packageJson.version);
16
+
17
+ program
18
+ .command('generate')
19
+ .description('Generate fetch client code')
20
+ .option('-i, --input <file>', 'input specification file')
21
+ .option('-o, --output <file>', 'output file path')
22
+ .action((options) => {
23
+ console.log('Generating fetch client...');
24
+ console.log('Input:', options.input);
25
+ console.log('Output:', options.output);
26
+ // Implementation will go here
27
+ });
28
+
29
+ program.parse();
package/index.js ADDED
@@ -0,0 +1,4 @@
1
+ // fetch-client-generator main entry point
2
+ export default {
3
+ // Main functionality will be implemented here
4
+ };
package/package.json ADDED
@@ -0,0 +1,29 @@
1
+ {
2
+ "name": "fetch-client-generator",
3
+ "version": "1.0.1",
4
+ "description": "A tool for generating fetch-based HTTP client code",
5
+ "main": "index.js",
6
+ "type": "module",
7
+ "bin": {
8
+ "fetch-client-generator": "./bin/cli.js"
9
+ },
10
+ "scripts": {
11
+ "test": "mocha"
12
+ },
13
+ "keywords": [
14
+ "fetch",
15
+ "client",
16
+ "generator",
17
+ "http",
18
+ "api"
19
+ ],
20
+ "author": "",
21
+ "license": "ISC",
22
+ "dependencies": {
23
+ "commander": "^14.0.0"
24
+ },
25
+ "devDependencies": {
26
+ "chai": "^5.2.0",
27
+ "mocha": "^11.7.1"
28
+ }
29
+ }
@@ -0,0 +1,26 @@
1
+ import { expect } from 'chai';
2
+ import { exec } from 'child_process';
3
+ import path from 'path';
4
+ import { fileURLToPath } from 'url';
5
+
6
+ const __filename = fileURLToPath(import.meta.url);
7
+ const __dirname = path.dirname(__filename);
8
+
9
+ describe('CLI', () => {
10
+ it('should show help when no arguments provided', (done) => {
11
+ const cliPath = path.join(__dirname, '../bin/cli.js');
12
+ exec(`node ${cliPath} --help`, (error, stdout, stderr) => {
13
+ expect(stdout).to.include('fetch-client-generator');
14
+ expect(stdout).to.include('generate');
15
+ done();
16
+ });
17
+ });
18
+
19
+ it('should show version', (done) => {
20
+ const cliPath = path.join(__dirname, '../bin/cli.js');
21
+ exec(`node ${cliPath} --version`, (error, stdout, stderr) => {
22
+ expect(stdout.trim()).to.match(/^\d+\.\d+\.\d+$/);
23
+ done();
24
+ });
25
+ });
26
+ });
@@ -0,0 +1,8 @@
1
+ import { expect } from 'chai';
2
+ import fetchClientGenerator from '../index.js';
3
+
4
+ describe('fetch-client-generator', () => {
5
+ it('should export an object', () => {
6
+ expect(fetchClientGenerator).to.be.an('object');
7
+ });
8
+ });