Skip to content

Commit fc868f0

Browse files
committed
refactor: run with retry
1 parent 1ceffb5 commit fc868f0

File tree

12 files changed

+106
-61
lines changed

12 files changed

+106
-61
lines changed

.vscode/settings.json

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
{
2+
"cSpell.words": [
3+
"yocto"
4+
]
5+
}

README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ For local development, follow the [Visual Studio Marketplace](https://code.visua
4141
### Example Workflow
4242

4343
```yaml
44-
name: Release
44+
name: Publish Extension
4545

4646
permissions:
4747
contents: write
@@ -79,7 +79,7 @@ jobs:
7979
run: npx vsce package --no-dependencies
8080

8181
# Publish extension to all platforms
82-
# Or you can skip publishing to specific platforms in CI and run npx vsxpub locally without configuring secrets
82+
# Or skip CI publishing and run `npx vsxpub` locally without configuring secrets
8383
- name: Publish Extension
8484
run: npx vsxpub --no-dependencies
8585
env:

package.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,11 +62,12 @@
6262
"bumpp": "catalog:cli",
6363
"eslint": "catalog:lint",
6464
"lint-staged": "catalog:lint",
65+
"p-retry": "catalog:inline",
6566
"pncat": "catalog:cli",
6667
"simple-git-hooks": "catalog:lint",
6768
"taze": "catalog:cli",
6869
"tsx": "catalog:script",
69-
"typescript": "catalog:dev",
70+
"typescript": "catalog:tsc",
7071
"unbuild": "catalog:build",
7172
"vitest": "catalog:test"
7273
},

pncat.config.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,10 @@ export default defineConfig({
66
name: 'node',
77
match: ['yocto-spinner'],
88
},
9+
{
10+
name: 'inline',
11+
match: ['p-retry'],
12+
},
913
]),
1014
postRun: 'eslint --fix "**/package.json" "**/pnpm-workspace.yaml"',
1115
})

pnpm-lock.yaml

Lines changed: 26 additions & 5 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

pnpm-workspace.yaml

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,8 @@ catalogs:
66
bumpp: ^10.3.1
77
pncat: ^0.7.3
88
taze: ^19.8.1
9-
dev:
10-
typescript: ^5.9.3
9+
inline:
10+
p-retry: ^7.1.1
1111
lint:
1212
'@antfu/eslint-config': ^6.0.0
1313
eslint: ^9.38.0
@@ -24,6 +24,8 @@ catalogs:
2424
tsx: ^4.20.6
2525
test:
2626
vitest: ^3.2.4
27+
tsc:
28+
typescript: ^5.9.3
2729
types:
2830
'@types/node': ^24.9.1
2931
onlyBuiltDependencies:

src/cli.ts

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import type { CAC } from 'cac'
2-
import type { CommandOptions, PublishOptions } from './types'
2+
import type { CommandOptions, Options } from './types'
33
import { existsSync } from 'node:fs'
44
import process from 'node:process'
55
import c from 'ansis'
@@ -90,7 +90,7 @@ catch (error) {
9090
process.exit(1)
9191
}
9292

93-
async function execCommand(cmd: string, args: string[], config: PublishOptions) {
93+
async function execCommand(cmd: string, args: string[], config: Options) {
9494
const env = {
9595
...process.env,
9696
GITHUB_TOKEN: config.githubToken,
@@ -101,7 +101,7 @@ async function execCommand(cmd: string, args: string[], config: PublishOptions)
101101
await execa(cmd, args, { env, stdio: 'inherit' })
102102
}
103103

104-
async function createPackage(config: PublishOptions) {
104+
async function createPackage(config: Options) {
105105
const args = normalizeArgs(['vsce', 'package'], config)
106106
return await runWithRetry({
107107
config,
@@ -117,7 +117,7 @@ async function createPackage(config: PublishOptions) {
117117
})
118118
}
119119

120-
async function publishToVsce(vsix: string, config: PublishOptions) {
120+
async function publishToVsce(vsix: string, config: Options) {
121121
const exec = async (args: string[]) => {
122122
return await runWithRetry({
123123
config,
@@ -141,7 +141,7 @@ async function publishToVsce(vsix: string, config: PublishOptions) {
141141
return await exec(normalizeArgs(['vsce', 'publish'], config))
142142
}
143143

144-
async function publishToOvsx(vsix: string, config: PublishOptions) {
144+
async function publishToOvsx(vsix: string, config: Options) {
145145
const args = normalizeArgs(['ovsx', 'publish', vsix], config)
146146
return await runWithRetry({
147147
config,
@@ -157,7 +157,7 @@ async function publishToOvsx(vsix: string, config: PublishOptions) {
157157
})
158158
}
159159

160-
async function publishToGit(vsix: string, config: PublishOptions) {
160+
async function publishToGit(vsix: string, config: Options) {
161161
const args = ['release', 'upload', config.tag, vsix, '--repo', config.repo, '--clobber']
162162
return await runWithRetry({
163163
config,
@@ -173,7 +173,7 @@ async function publishToGit(vsix: string, config: PublishOptions) {
173173
})
174174
}
175175

176-
function normalizeArgs(args: string[], options: PublishOptions) {
176+
function normalizeArgs(args: string[], options: Options) {
177177
if (!options.dependencies) {
178178
args.push('--no-dependencies')
179179
}

src/config.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import type { CommandOptions, Platform, PublishOptions } from './types'
1+
import type { CommandOptions, Options, Platform } from './types'
22
import process from 'node:process'
33
import c from 'ansis'
44
import { createConfigLoader } from 'unconfig'
@@ -14,7 +14,7 @@ function normalizeConfig(options: Partial<CommandOptions>) {
1414
return options
1515
}
1616

17-
export async function resolveConfig(options: Partial<CommandOptions>): Promise<PublishOptions> {
17+
export async function resolveConfig(options: Partial<CommandOptions>): Promise<Options> {
1818
const defaults = { ...DEFAULT_PUBLISH_OPTIONS }
1919
options = normalizeConfig(options)
2020

@@ -80,5 +80,5 @@ export async function resolveConfig(options: Partial<CommandOptions>): Promise<P
8080
}
8181
}
8282

83-
return config as PublishOptions
83+
return config as Options
8484
}

src/index.ts

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1,8 @@
1-
export {}
1+
import type { Options } from './types'
2+
3+
export * from './constants'
4+
export * from './types'
5+
6+
export function defineConfig(config: Partial<Options>) {
7+
return config
8+
}

src/types.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,4 +67,4 @@ export interface CommandOptions extends CommonOptions {
6767
ovsxPat?: string
6868
}
6969

70-
export type PublishOptions = Required<CommandOptions>
70+
export type Options = Required<CommandOptions>

0 commit comments

Comments
 (0)