@xcelera/cli 1.2.2 → 1.4.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.
Files changed (48) hide show
  1. package/dist/action.js +81 -18
  2. package/dist/action.js.map +1 -1
  3. package/dist/cli.js +94 -19
  4. package/dist/cli.js.map +1 -0
  5. package/package.json +10 -3
  6. package/.commitlintrc.json +0 -3
  7. package/.devcontainer/devcontainer.json +0 -41
  8. package/.env.example +0 -61
  9. package/.gitattributes +0 -3
  10. package/.github/dependabot.yml +0 -30
  11. package/.github/workflows/check-dist.yml +0 -72
  12. package/.github/workflows/ci.yml +0 -70
  13. package/.github/workflows/codeql-analysis.yml +0 -48
  14. package/.github/workflows/licensed.yml +0 -74
  15. package/.github/workflows/linter.yml +0 -53
  16. package/.github/workflows/release.yml +0 -56
  17. package/.licensed.yml +0 -18
  18. package/.licenses/npm/@actions/core.dep.yml +0 -20
  19. package/.licenses/npm/@actions/exec.dep.yml +0 -20
  20. package/.licenses/npm/@actions/http-client.dep.yml +0 -32
  21. package/.licenses/npm/@actions/io.dep.yml +0 -20
  22. package/.licenses/npm/@fastify/busboy.dep.yml +0 -30
  23. package/.licenses/npm/tunnel.dep.yml +0 -35
  24. package/.licenses/npm/undici.dep.yml +0 -34
  25. package/.markdown-lint.yml +0 -24
  26. package/.node-version +0 -1
  27. package/.nvmrc +0 -1
  28. package/.prettierignore +0 -5
  29. package/.prettierrc.yml +0 -16
  30. package/.vscode/launch.json +0 -15
  31. package/.yaml-lint.yml +0 -14
  32. package/CODEOWNERS +0 -7
  33. package/action.yml +0 -29
  34. package/badges/coverage.svg +0 -1
  35. package/eslint.config.mjs +0 -81
  36. package/jest.config.js +0 -40
  37. package/release.config.mjs +0 -12
  38. package/rollup.config.ts +0 -30
  39. package/script/release +0 -133
  40. package/src/action.ts +0 -35
  41. package/src/api.ts +0 -46
  42. package/src/cli.ts +0 -79
  43. package/src/git.ts +0 -66
  44. package/src/types/git.ts +0 -5
  45. package/src/types/parse-github-url.d.ts +0 -12
  46. package/tsconfig.base.json +0 -23
  47. package/tsconfig.eslint.json +0 -18
  48. package/tsconfig.json +0 -11
package/script/release DELETED
@@ -1,133 +0,0 @@
1
- #!/bin/bash
2
-
3
- # Exit early
4
- # See: https://www.gnu.org/savannah-checkouts/gnu/bash/manual/bash.html#The-Set-Builtin
5
- set -e
6
-
7
- # About:
8
- #
9
- # This is a helper script to tag and push a new release. GitHub Actions use
10
- # release tags to allow users to select a specific version of the action to use.
11
- #
12
- # See: https://github.com/actions/typescript-action#publishing-a-new-release
13
- # See: https://github.com/actions/toolkit/blob/master/docs/action-versioning.md#recommendations
14
- #
15
- # This script will do the following:
16
- #
17
- # 1. Retrieve the latest release tag
18
- # 2. Display the latest release tag
19
- # 3. Prompt the user for a new release tag
20
- # 4. Validate the new release tag
21
- # 5. Remind user to update the version field in package.json
22
- # 6. Tag a new release
23
- # 7. Set 'is_major_release' variable
24
- # 8. Point separate major release tag (e.g. v1, v2) to the new release
25
- # 9. Push the new tags (with commits, if any) to remote
26
- # 10. If this is a major release, create a 'releases/v#' branch and push
27
- #
28
- # Usage:
29
- #
30
- # script/release
31
-
32
- # Variables
33
- semver_tag_regex='v[0-9]+\.[0-9]+\.[0-9]+$'
34
- semver_tag_glob='v[0-9].[0-9].[0-9]*'
35
- git_remote='origin'
36
- major_semver_tag_regex='\(v[0-9]*\)'
37
-
38
- # Terminal colors
39
- OFF='\033[0m'
40
- BOLD_RED='\033[1;31m'
41
- BOLD_GREEN='\033[1;32m'
42
- BOLD_BLUE='\033[1;34m'
43
- BOLD_PURPLE='\033[1;35m'
44
- BOLD_UNDERLINED='\033[1;4m'
45
- BOLD='\033[1m'
46
-
47
- # 1. Retrieve the latest release tag
48
- if ! latest_tag=$(git describe --abbrev=0 --match="$semver_tag_glob"); then
49
- # There are no existing release tags
50
- echo -e "No tags found (yet) - Continue to create and push your first tag"
51
- latest_tag="[unknown]"
52
- fi
53
-
54
- # 2. Display the latest release tag
55
- echo -e "The latest release tag is: ${BOLD_BLUE}${latest_tag}${OFF}"
56
-
57
- # 3. Prompt the user for a new release tag
58
- read -r -p 'Enter a new release tag (vX.X.X format): ' new_tag
59
-
60
- # 4. Validate the new release tag
61
- if echo "$new_tag" | grep -q -E "$semver_tag_regex"; then
62
- # Release tag is valid
63
- echo -e "Tag: ${BOLD_BLUE}$new_tag${OFF} is valid syntax"
64
- else
65
- # Release tag is not in `vX.X.X` format
66
- echo -e "Tag: ${BOLD_BLUE}$new_tag${OFF} is ${BOLD_RED}not valid${OFF} (must be in ${BOLD}vX.X.X${OFF} format)"
67
- exit 1
68
- fi
69
-
70
- # 5. Remind user to update the version field in package.json
71
- echo -e -n "Make sure the version field in package.json is ${BOLD_BLUE}$new_tag${OFF}. Yes? [Y/${BOLD_UNDERLINED}n${OFF}] "
72
- read -r YN
73
-
74
- if [[ ! ($YN == "y" || $YN == "Y") ]]; then
75
- # Package.json version field is not up to date
76
- echo -e "Please update the package.json version to ${BOLD_PURPLE}$new_tag${OFF} and commit your changes"
77
- exit 1
78
- fi
79
-
80
- # 6. Tag a new release
81
- git tag "$new_tag" --annotate --message "$new_tag Release"
82
- echo -e "Tagged: ${BOLD_GREEN}$new_tag${OFF}"
83
-
84
- # 7. Set 'is_major_release' variable
85
- new_major_release_tag=$(expr "$new_tag" : "$major_semver_tag_regex")
86
-
87
- if [[ "$latest_tag" = "[unknown]" ]]; then
88
- # This is the first major release
89
- is_major_release='yes'
90
- else
91
- # Compare the major version of the latest tag with the new tag
92
- latest_major_release_tag=$(expr "$latest_tag" : "$major_semver_tag_regex")
93
-
94
- if ! [[ "$new_major_release_tag" = "$latest_major_release_tag" ]]; then
95
- is_major_release='yes'
96
- else
97
- is_major_release='no'
98
- fi
99
- fi
100
-
101
- # 8. Point separate major release tag (e.g. v1, v2) to the new release
102
- if [ $is_major_release = 'yes' ]; then
103
- # Create a new major version tag and point it to this release
104
- git tag "$new_major_release_tag" --annotate --message "$new_major_release_tag Release"
105
- echo -e "New major version tag: ${BOLD_GREEN}$new_major_release_tag${OFF}"
106
- else
107
- # Update the major version tag to point it to this release
108
- git tag "$latest_major_release_tag" --force --annotate --message "Sync $latest_major_release_tag tag with $new_tag"
109
- echo -e "Synced ${BOLD_GREEN}$latest_major_release_tag${OFF} with ${BOLD_GREEN}$new_tag${OFF}"
110
- fi
111
-
112
- # 9. Push the new tags (with commits, if any) to remote
113
- git push --follow-tags
114
-
115
- if [ $is_major_release = 'yes' ]; then
116
- # New major version tag is pushed with the '--follow-tags' flags
117
- echo -e "Tags: ${BOLD_GREEN}$new_major_release_tag${OFF} and ${BOLD_GREEN}$new_tag${OFF} pushed to remote"
118
- else
119
- # Force push the updated major version tag
120
- git push $git_remote "$latest_major_release_tag" --force
121
- echo -e "Tags: ${BOLD_GREEN}$latest_major_release_tag${OFF} and ${BOLD_GREEN}$new_tag${OFF} pushed to remote"
122
- fi
123
-
124
- # 10. If this is a major release, create a 'releases/v#' branch and push
125
- if [ $is_major_release = 'yes' ]; then
126
- git branch "releases/$new_major_release_tag" "$new_major_release_tag"
127
- echo -e "Branch: ${BOLD_BLUE}releases/$new_major_release_tag${OFF} created from ${BOLD_BLUE}$new_major_release_tag${OFF} tag"
128
- git push --set-upstream $git_remote "releases/$new_major_release_tag"
129
- echo -e "Branch: ${BOLD_GREEN}releases/$new_major_release_tag${OFF} pushed to remote"
130
- fi
131
-
132
- # Completed
133
- echo -e "${BOLD_GREEN}Done!${OFF}"
package/src/action.ts DELETED
@@ -1,35 +0,0 @@
1
- import * as core from '@actions/core'
2
- import * as github from '@actions/github'
3
- import { requestAudit } from './api.js'
4
-
5
- run()
6
-
7
- async function run(): Promise<void> {
8
- try {
9
- const url = core.getInput('url', { required: true })
10
- const token = core.getInput('token', { required: true })
11
-
12
- core.debug(`Auditing URL: ${url}`)
13
-
14
- core.debug('Calling Xcelera audit API...')
15
- const githubContext = {
16
- owner: github.context.repo.owner,
17
- repo: github.context.repo.repo,
18
- sha: github.context.sha
19
- }
20
- const response = await requestAudit(url, token, githubContext)
21
-
22
- // Set outputs
23
- core.setOutput('auditId', response.auditId)
24
- core.setOutput('status', response.status)
25
-
26
- core.info(`✅ Audit scheduled successfully!`)
27
- core.info(`Audit ID: ${response.auditId}`)
28
- core.info(`Status: ${response.status}`)
29
- } catch (error) {
30
- const errorMessage =
31
- error instanceof Error ? error.message : 'Unknown error occurred'
32
- core.setFailed(errorMessage)
33
- core.setOutput('status', 'failed')
34
- }
35
- }
package/src/api.ts DELETED
@@ -1,46 +0,0 @@
1
- import type { GitContext } from './types/git.js'
2
-
3
- export interface AuditResponse {
4
- auditId: string
5
- status: string
6
- }
7
-
8
- export async function requestAudit(
9
- url: string,
10
- token: string,
11
- github: GitContext
12
- ): Promise<AuditResponse> {
13
- const apiUrl = `${getApiBaseUrl()}/api/v1/audit`
14
-
15
- const response = await fetch(apiUrl, {
16
- method: 'POST',
17
- headers: {
18
- 'Content-Type': 'application/json',
19
- Authorization: `Bearer ${token}`
20
- },
21
- body: JSON.stringify({
22
- url,
23
- github
24
- })
25
- })
26
-
27
- if (!response.ok) {
28
- const errorText = await response.text()
29
- throw new Error(
30
- `API request failed: ${response.status} ${response.statusText} - ${errorText}`
31
- )
32
- }
33
-
34
- const data = await response.json()
35
- return data as AuditResponse
36
- }
37
-
38
- function getApiBaseUrl(): string {
39
- if (
40
- process.env.NODE_ENV === 'development' ||
41
- process.env.GITHUB_ACTIONS !== 'true'
42
- ) {
43
- return 'http://localhost:3000'
44
- }
45
- return 'https://xcelera.dev'
46
- }
package/src/cli.ts DELETED
@@ -1,79 +0,0 @@
1
- #!/usr/bin/env node
2
-
3
- import { parseArgs } from 'node:util'
4
-
5
- import { requestAudit } from './api.js'
6
- import { inferGitContext } from './git.js'
7
-
8
- const options = {
9
- url: {
10
- type: 'string' as const,
11
- required: true
12
- },
13
- token: {
14
- type: 'string' as const,
15
- required: true,
16
- default: process.env.XCELERA_TOKEN
17
- }
18
- }
19
-
20
- const { positionals, values } = parseArgs({
21
- options,
22
- allowPositionals: true,
23
- args: process.argv.slice(2)
24
- })
25
-
26
- const command = positionals[0]
27
-
28
- if (!command) {
29
- console.error('A command is required. Only "audit" is currently supported.')
30
- printHelp()
31
- process.exit(1)
32
- }
33
-
34
- if (command === 'help') {
35
- printHelp()
36
- }
37
-
38
- if (command !== 'audit') {
39
- console.error('Invalid command. Only "audit" is currently supported.')
40
- printHelp()
41
- process.exit(1)
42
- }
43
-
44
- const { url, token } = values
45
-
46
- if (!url) {
47
- console.error('URL is required. Use --url <url> to specify the URL to audit.')
48
- process.exit(1)
49
- }
50
-
51
- if (!token) {
52
- console.error(
53
- 'A token is required. Use --token or set XCELERA_TOKEN environment variable.'
54
- )
55
- process.exit(1)
56
- }
57
-
58
- try {
59
- const githubContext = inferGitContext()
60
- await requestAudit(url, token, githubContext)
61
- console.log('✅ Audit scheduled successfully!')
62
- } catch (error) {
63
- const errorMessage =
64
- error instanceof Error ? error.message : 'Unknown error occurred'
65
- console.error(`❌ ${errorMessage}`)
66
- process.exit(1)
67
- }
68
-
69
- function printHelp() {
70
- console.log('Usage: xcelera audit --url <url> [--token <token>]')
71
- console.log('')
72
- console.log('Options:')
73
- console.log(
74
- ' --token <token> The xcelera API token to use for authentication.'
75
- )
76
- console.log('Can also be set with the XCELERA_TOKEN environment variable.')
77
- console.log(' --url <url> The URL to audit.')
78
- console.log('')
79
- }
package/src/git.ts DELETED
@@ -1,66 +0,0 @@
1
- import { execSync } from 'node:child_process'
2
- import parseGithubUrl from 'parse-github-url'
3
- import type { GitContext } from './types/git.js'
4
-
5
- export function inferGitContext(): GitContext {
6
- if (!isGitRepository()) {
7
- throw new Error('Not git repository detected.')
8
- }
9
-
10
- const remoteUrl = getRemoteUrl()
11
-
12
- const parsed = parseGithubUrl(remoteUrl)
13
- if (!parsed || !parsed.owner || !parsed.repo) {
14
- throw new Error(
15
- `Could not parse GitHub URL: ${remoteUrl}. Expected format: https://github.com/owner/repo or git@github.com:owner/repo`
16
- )
17
- }
18
-
19
- const { owner, repo } = parsed
20
-
21
- const sha = getCurrentSha()
22
-
23
- // repo is parsed as owner/repo but we want to use just the repo name
24
- const repoName = repo.replace(`${owner}/`, '')
25
-
26
- return { owner, repo: repoName, sha }
27
- }
28
-
29
- function isGitRepository(): boolean {
30
- try {
31
- execSync('git rev-parse --git-dir', { stdio: 'ignore' })
32
- return true
33
- } catch {
34
- return false
35
- }
36
- }
37
-
38
- function getRemoteUrl(): string {
39
- try {
40
- const remoteUrl = execSync('git remote get-url origin', {
41
- encoding: 'utf8',
42
- stdio: 'pipe'
43
- }).trim()
44
-
45
- if (!remoteUrl) {
46
- throw new Error('No origin remote found')
47
- }
48
-
49
- return remoteUrl
50
- } catch {
51
- throw new Error(
52
- 'Could not determine git remote URL. Please ensure you have an origin remote configured.'
53
- )
54
- }
55
- }
56
-
57
- function getCurrentSha(): string {
58
- try {
59
- return execSync('git rev-parse HEAD', {
60
- encoding: 'utf8',
61
- stdio: 'pipe'
62
- }).trim()
63
- } catch {
64
- throw new Error('Could not determine current commit SHA')
65
- }
66
- }
package/src/types/git.ts DELETED
@@ -1,5 +0,0 @@
1
- export interface GitContext {
2
- owner: string
3
- repo: string
4
- sha: string
5
- }
@@ -1,12 +0,0 @@
1
- declare module 'parse-github-url' {
2
- interface ParsedGithubUrl {
3
- owner: string
4
- name: string
5
- repo: string
6
- branch?: string
7
- }
8
-
9
- function parseGithubUrl(url: string): ParsedGithubUrl | null
10
-
11
- export default parseGithubUrl
12
- }
@@ -1,23 +0,0 @@
1
- {
2
- "$schema": "https://json.schemastore.org/tsconfig",
3
- "compilerOptions": {
4
- "allowSyntheticDefaultImports": true,
5
- "declaration": false,
6
- "declarationMap": false,
7
- "esModuleInterop": true,
8
- "forceConsistentCasingInFileNames": true,
9
- "isolatedModules": true,
10
- "lib": ["ES2022"],
11
- "module": "NodeNext",
12
- "moduleResolution": "NodeNext",
13
- "newLine": "lf",
14
- "noImplicitAny": true,
15
- "noUnusedLocals": true,
16
- "noUnusedParameters": false,
17
- "pretty": true,
18
- "resolveJsonModule": true,
19
- "strict": true,
20
- "strictNullChecks": true,
21
- "target": "ES2022"
22
- }
23
- }
@@ -1,18 +0,0 @@
1
- {
2
- "$schema": "https://json.schemastore.org/tsconfig",
3
- "extends": "./tsconfig.base.json",
4
- "compilerOptions": {
5
- "allowJs": true,
6
- "noEmit": true
7
- },
8
- "exclude": ["dist", "node_modules"],
9
- "include": [
10
- "__fixtures__",
11
- "__tests__",
12
- "src",
13
- "eslint.config.mjs",
14
- "jest.config.js",
15
- "rollup.config.ts",
16
- "release.config.mjs"
17
- ]
18
- }
package/tsconfig.json DELETED
@@ -1,11 +0,0 @@
1
- {
2
- "$schema": "https://json.schemastore.org/tsconfig",
3
- "extends": "./tsconfig.base.json",
4
- "compilerOptions": {
5
- "module": "NodeNext",
6
- "moduleResolution": "NodeNext",
7
- "outDir": "./dist"
8
- },
9
- "exclude": ["__fixtures__", "__tests__", "coverage", "dist", "node_modules"],
10
- "include": ["src"]
11
- }