@xcelera/cli 0.0.1 → 1.1.0
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/.commitlintrc.json +3 -0
- package/.github/workflows/ci.yml +45 -0
- package/package.json +2 -1
- package/src/cli.ts +1 -6
- package/dist/cli.js +0 -95
package/.github/workflows/ci.yml
CHANGED
|
@@ -47,6 +47,11 @@ jobs:
|
|
|
47
47
|
test-action:
|
|
48
48
|
name: GitHub Actions Test
|
|
49
49
|
runs-on: ubuntu-latest
|
|
50
|
+
permissions:
|
|
51
|
+
contents: write # to be able to publish a GitHub release
|
|
52
|
+
issues: write # to be able to comment on released issues
|
|
53
|
+
pull-requests: write # to be able to comment on released pull requests
|
|
54
|
+
id-token: write # to enable use of OIDC for npm provenance
|
|
50
55
|
|
|
51
56
|
steps:
|
|
52
57
|
- name: Checkout
|
|
@@ -63,3 +68,43 @@ jobs:
|
|
|
63
68
|
- name: Print Output
|
|
64
69
|
id: output
|
|
65
70
|
run: echo "${{ steps.test-action.outputs.status }}"
|
|
71
|
+
|
|
72
|
+
- name: Release
|
|
73
|
+
env:
|
|
74
|
+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
|
75
|
+
NPM_TOKEN: ${{ secrets.NPM_TOKEN }}
|
|
76
|
+
run: npx semantic-release
|
|
77
|
+
|
|
78
|
+
release:
|
|
79
|
+
name: Release
|
|
80
|
+
runs-on: ubuntu-latest
|
|
81
|
+
permissions:
|
|
82
|
+
contents: write # to be able to publish a GitHub release
|
|
83
|
+
issues: write # to be able to comment on released issues
|
|
84
|
+
pull-requests: write # to be able to comment on released pull requests
|
|
85
|
+
id-token: write # to enable use of OIDC for npm provenance
|
|
86
|
+
|
|
87
|
+
steps:
|
|
88
|
+
- name: Checkout
|
|
89
|
+
uses: actions/checkout@v4
|
|
90
|
+
with:
|
|
91
|
+
fetch-depth: 0
|
|
92
|
+
|
|
93
|
+
- name: Setup Node.js
|
|
94
|
+
uses: actions/setup-node@v4
|
|
95
|
+
with:
|
|
96
|
+
node-version: 'lts/*'
|
|
97
|
+
|
|
98
|
+
- name: Install dependencies
|
|
99
|
+
run: npm clean-install
|
|
100
|
+
|
|
101
|
+
- name:
|
|
102
|
+
Verify the integrity of provenance attestations and registry
|
|
103
|
+
signatures for installed dependencies
|
|
104
|
+
run: npm audit signatures
|
|
105
|
+
|
|
106
|
+
- name: Release
|
|
107
|
+
env:
|
|
108
|
+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
|
109
|
+
NPM_TOKEN: ${{ secrets.NPM_TOKEN }}
|
|
110
|
+
run: npx semantic-release
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@xcelera/cli",
|
|
3
3
|
"description": "CLI for xcelera.dev",
|
|
4
|
-
"version": "
|
|
4
|
+
"version": "1.1.0",
|
|
5
5
|
"author": "",
|
|
6
6
|
"type": "module",
|
|
7
7
|
"repository": {
|
|
@@ -66,6 +66,7 @@
|
|
|
66
66
|
"prettier": "^3.6.2",
|
|
67
67
|
"prettier-eslint": "^16.4.2",
|
|
68
68
|
"rollup": "^4.44.2",
|
|
69
|
+
"semantic-release": "^24.2.7",
|
|
69
70
|
"ts-jest": "^29.4.0",
|
|
70
71
|
"ts-jest-resolver": "^2.0.1",
|
|
71
72
|
"typescript": "^5.8.3"
|
package/src/cli.ts
CHANGED
|
@@ -56,12 +56,7 @@ if (!token) {
|
|
|
56
56
|
}
|
|
57
57
|
|
|
58
58
|
try {
|
|
59
|
-
|
|
60
|
-
const githubContext = {
|
|
61
|
-
owner: 'xcelera-dev',
|
|
62
|
-
repo: 'app',
|
|
63
|
-
sha: 'fc0cb4434f8275ea67931f78dcd19f0f1c8f2366'
|
|
64
|
-
}
|
|
59
|
+
const githubContext = inferGitContext()
|
|
65
60
|
await requestAudit(url, token, githubContext)
|
|
66
61
|
console.log('✅ Audit scheduled successfully!')
|
|
67
62
|
} catch (error) {
|
package/dist/cli.js
DELETED
|
@@ -1,95 +0,0 @@
|
|
|
1
|
-
#!/usr/bin/env node
|
|
2
|
-
import { parseArgs } from 'node:util';
|
|
3
|
-
|
|
4
|
-
async function requestAudit(url, token, github) {
|
|
5
|
-
const apiUrl = `${getApiBaseUrl()}/api/v1/audit`;
|
|
6
|
-
const response = await fetch(apiUrl, {
|
|
7
|
-
method: 'POST',
|
|
8
|
-
headers: {
|
|
9
|
-
'Content-Type': 'application/json',
|
|
10
|
-
Authorization: `Bearer ${token}`
|
|
11
|
-
},
|
|
12
|
-
body: JSON.stringify({
|
|
13
|
-
url,
|
|
14
|
-
github
|
|
15
|
-
})
|
|
16
|
-
});
|
|
17
|
-
if (!response.ok) {
|
|
18
|
-
const errorText = await response.text();
|
|
19
|
-
throw new Error(`API request failed: ${response.status} ${response.statusText} - ${errorText}`);
|
|
20
|
-
}
|
|
21
|
-
const data = await response.json();
|
|
22
|
-
return data;
|
|
23
|
-
}
|
|
24
|
-
function getApiBaseUrl() {
|
|
25
|
-
if (process.env.NODE_ENV === 'development' ||
|
|
26
|
-
process.env.GITHUB_ACTIONS !== 'true') {
|
|
27
|
-
return 'http://localhost:3000';
|
|
28
|
-
}
|
|
29
|
-
return 'https://xcelera.dev';
|
|
30
|
-
}
|
|
31
|
-
|
|
32
|
-
const options = {
|
|
33
|
-
url: {
|
|
34
|
-
type: 'string',
|
|
35
|
-
required: true
|
|
36
|
-
},
|
|
37
|
-
token: {
|
|
38
|
-
type: 'string',
|
|
39
|
-
required: true,
|
|
40
|
-
default: process.env.XCELERA_TOKEN
|
|
41
|
-
}
|
|
42
|
-
};
|
|
43
|
-
const { positionals, values } = parseArgs({
|
|
44
|
-
options,
|
|
45
|
-
allowPositionals: true,
|
|
46
|
-
args: process.argv.slice(2)
|
|
47
|
-
});
|
|
48
|
-
const command = positionals[0];
|
|
49
|
-
if (!command) {
|
|
50
|
-
console.error('A command is required. Only "audit" is currently supported.');
|
|
51
|
-
printHelp();
|
|
52
|
-
process.exit(1);
|
|
53
|
-
}
|
|
54
|
-
if (command === 'help') {
|
|
55
|
-
printHelp();
|
|
56
|
-
}
|
|
57
|
-
if (command !== 'audit') {
|
|
58
|
-
console.error('Invalid command. Only "audit" is currently supported.');
|
|
59
|
-
printHelp();
|
|
60
|
-
process.exit(1);
|
|
61
|
-
}
|
|
62
|
-
const { url, token } = values;
|
|
63
|
-
if (!url) {
|
|
64
|
-
console.error('URL is required. Use --url <url> to specify the URL to audit.');
|
|
65
|
-
process.exit(1);
|
|
66
|
-
}
|
|
67
|
-
if (!token) {
|
|
68
|
-
console.error('A token is required. Use --token or set XCELERA_TOKEN environment variable.');
|
|
69
|
-
process.exit(1);
|
|
70
|
-
}
|
|
71
|
-
try {
|
|
72
|
-
// const githubContext = inferGitContext()
|
|
73
|
-
const githubContext = {
|
|
74
|
-
owner: 'xcelera-dev',
|
|
75
|
-
repo: 'app',
|
|
76
|
-
sha: 'fc0cb4434f8275ea67931f78dcd19f0f1c8f2366'
|
|
77
|
-
};
|
|
78
|
-
await requestAudit(url, token, githubContext);
|
|
79
|
-
console.log('✅ Audit scheduled successfully!');
|
|
80
|
-
}
|
|
81
|
-
catch (error) {
|
|
82
|
-
const errorMessage = error instanceof Error ? error.message : 'Unknown error occurred';
|
|
83
|
-
console.error(`❌ ${errorMessage}`);
|
|
84
|
-
process.exit(1);
|
|
85
|
-
}
|
|
86
|
-
function printHelp() {
|
|
87
|
-
console.log('Usage: xcelera audit --url <url> [--token <token>]');
|
|
88
|
-
console.log('');
|
|
89
|
-
console.log('Options:');
|
|
90
|
-
console.log(' --token <token> The xcelera API token to use for authentication.');
|
|
91
|
-
console.log('Can also be set with the XCELERA_TOKEN environment variable.');
|
|
92
|
-
console.log(' --url <url> The URL to audit.');
|
|
93
|
-
console.log('');
|
|
94
|
-
}
|
|
95
|
-
//# sourceMappingURL=cli.js.map
|