Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions .changeset/fix-worma-vscode-2026-07-25.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
---
"wormajs": patch
"worma-vscode": patch
---

Fix OpenAPI circular-reference detection by replacing `Object.prototype.hasOwnProperty.call` with the native `Object.hasOwn`, and stabilize unit tests. Update VS Code extension to use `Date.now()` for id generation, fix import ordering, and adjust publish script order.
2 changes: 1 addition & 1 deletion .github/workflows/pr.yml
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ jobs:
- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: 20
node-version: 22
registry-url: 'https://registry.npmjs.org'
cache: pnpm

Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ jobs:
- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: 20
node-version: 22
registry-url: 'https://registry.npmjs.org'
cache: pnpm

Expand All @@ -51,7 +51,7 @@ jobs:
- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: 20
node-version: 22
registry-url: 'https://registry.npmjs.org'
cache: pnpm

Expand Down
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,9 @@ out
dist
docs/.source/
dist-ssr
*.tsbuildinfo
tsc_out.txt
**/tsc_out.txt
*.vsix
.vscode-test
.vite-ssg-dist
Expand Down
2 changes: 1 addition & 1 deletion benchmark/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,6 @@
"vite": "^7.3.1",
"vue": "^3.5.17",
"vue-echarts": "^7.0.3",
"wormajs": "workspace:*"
"wormajs": "latest"
}
}
2 changes: 1 addition & 1 deletion docs/src/components/home/Cta.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ export default function Cta() {
try {
await navigator.clipboard.writeText(AGENT_PROMPT)
setToast(true)
setTimeout(() => setToast(false), 2500)
setTimeout(setToast, 2500, false)
}
catch {
// ignore clipboard errors
Expand Down
2 changes: 1 addition & 1 deletion docs/src/components/home/Hero.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -194,7 +194,7 @@ export default function Hero() {
try {
await navigator.clipboard.writeText(AGENT_PROMPT)
setToast(true)
setTimeout(() => setToast(false), 2500)
setTimeout(setToast, 2500, false)
}
catch {
// ignore clipboard errors
Expand Down
2 changes: 1 addition & 1 deletion examples/commonjs/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,6 @@
"axios": "^1.17.0"
},
"devDependencies": {
"wormajs": "workspace:*"
"wormajs": "latest"
}
}
2 changes: 1 addition & 1 deletion examples/esm/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,6 @@
"ky": "^2.0.2"
},
"devDependencies": {
"wormajs": "workspace:*"
"wormajs": "latest"
}
}
2 changes: 1 addition & 1 deletion examples/monorepo/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,6 @@
"start": "npm run gen:all && pnpm start:alova && pnpm start:axios && pnpm start:fetch && pnpm start:ky"
},
"devDependencies": {
"wormajs": "workspace:*"
"wormajs": "latest"
}
}
2 changes: 1 addition & 1 deletion examples/typescript/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,6 @@
"devDependencies": {
"tsx": "^4.22.4",
"typescript": "^5.9.3",
"wormajs": "workspace:*"
"wormajs": "latest"
}
}
9 changes: 5 additions & 4 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,11 @@
"url": "https://github.com/alovajs/devtools/issues"
},
"engines": {
"node": ">=20.19.0",
"node": ">=22.0.0",
"pnpm": ">=9.1.0"
},
"scripts": {
"test": "run-s test:*",
"test": "run-s \"test:*\"",
"test:e2e": "nr build && nr --filter=./packages/vscode-extension test:e2e",
"test:unit": "vitest run --exclude '**/e2e*/**'",
"test:unit:coverage": "vitest run --exclude '**/e2e*/**' --coverage",
Expand All @@ -33,7 +33,7 @@
"changeset:beta": "changeset pre enter beta",
"changeset:pre.exit": "changeset pre exit",
"changeset:version": "tsx scripts/version.ts",
"build": "nr --filter=./packages/* build",
"build": "nr --filter=\"./packages/*\" build",
"release": "tsx scripts/release.ts"
},
"devDependencies": {
Expand Down Expand Up @@ -76,7 +76,8 @@
"resolutions": {
"unplugin": "catalog:build",
"vite": "catalog:build",
"vite-plugin-inspect": "catalog:build"
"vite-plugin-inspect": "catalog:build",
"wormajs": "workspace:*"
},
"lint-staged": {
"*": "npm run lintf"
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { Commands, executeCommand, expect, openFile, setupTest } from '../../ctx'
import { Commands, executeCommand, expect, openFile, setupTest } from '../../ctx.js'

// The harness launches this action once per declared fixture and tells us
// which one via `E2E_FIXTURE`. The expected config file name follows the
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
import { createRunner } from '../../runner'
import { createRunner } from '../../runner.js'

export const run = createRunner(__dirname)
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import sinon from 'sinon'
import { Commands, executeCommand, expect, MockWorma, setupTest } from '../../ctx'
import { Commands, executeCommand, expect, MockWorma, setupTest } from '../../ctx.js'

setupTest('create-config command', () => {
it('invokes worma.createConfig exactly once', async () => {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
import { createRunner } from '../../runner'
import { createRunner } from '../../runner.js'

export const run = createRunner(__dirname)
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { getExt, is, setupTest } from '../../ctx'
import { getExt, is, setupTest } from '../../ctx.js'

setupTest('extension-activation', () => {
it('extension is active after startup', () => {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
import { createRunner } from '../../runner'
import { createRunner } from '../../runner.js'

export const run = createRunner(__dirname)
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import sinon from 'sinon'
import { Commands, executeCommand, expect, MockWorma, setupTest } from '../../ctx'
import { Commands, executeCommand, expect, MockWorma, setupTest } from '../../ctx.js'

setupTest('generate-api command', () => {
it('runs the generator through the refresh action', async () => {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
import { createRunner } from '../../runner'
import { createRunner } from '../../runner.js'

export const run = createRunner(__dirname)
4 changes: 2 additions & 2 deletions packages/vscode-extension/e2e/ctx.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,10 @@ import Chai from 'chai'
import Snapshot from 'chai-jest-snapshot'
import sinon from 'sinon'
import { commands, extensions, Uri, window, workspace } from 'vscode'
import { Meta } from './test'
import { Meta } from './test.js'

Chai.use(Snapshot)
export * from './test'
export * from './test.js'
export const expect = Chai.expect
export { is, not }
export function timeout(ms = 1000) {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import sinon from 'sinon'
import { Commands, executeCommand, expect, getExt, is, MockWorma, openFile, setupTest } from '../../ctx'
import { Commands, executeCommand, expect, getExt, is, MockWorma, openFile, setupTest } from '../../ctx.js'

setupTest('commonjs', () => {
it('opens entry file', async () => {
Expand Down
2 changes: 1 addition & 1 deletion packages/vscode-extension/e2e/frameworks/commonjs/index.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
import { createRunner } from '../../runner'
import { createRunner } from '../../runner.js'

export const run = createRunner(__dirname)
2 changes: 1 addition & 1 deletion packages/vscode-extension/e2e/frameworks/esm/basic.test.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import sinon from 'sinon'
import { Commands, executeCommand, expect, getExt, is, MockWorma, openFile, setupTest } from '../../ctx'
import { Commands, executeCommand, expect, getExt, is, MockWorma, openFile, setupTest } from '../../ctx.js'

setupTest('esm', () => {
it('opens entry file', async () => {
Expand Down
2 changes: 1 addition & 1 deletion packages/vscode-extension/e2e/frameworks/esm/index.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
import { createRunner } from '../../runner'
import { createRunner } from '../../runner.js'

export const run = createRunner(__dirname)
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import sinon from 'sinon'
import { Commands, executeCommand, expect, getExt, is, MockWorma, openFile, setupTest } from '../../ctx'
import { Commands, executeCommand, expect, getExt, is, MockWorma, openFile, setupTest } from '../../ctx.js'

setupTest('monorepo', () => {
it('opens entry file', async () => {
Expand Down
2 changes: 1 addition & 1 deletion packages/vscode-extension/e2e/frameworks/monorepo/index.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
import { createRunner } from '../../runner'
import { createRunner } from '../../runner.js'

export const run = createRunner(__dirname)
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import sinon from 'sinon'
import { Commands, executeCommand, expect, getExt, is, MockWorma, openFile, setupTest } from '../../ctx'
import { Commands, executeCommand, expect, getExt, is, MockWorma, openFile, setupTest } from '../../ctx.js'

setupTest('typescript', () => {
it('opens entry file', async () => {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
import { createRunner } from '../../runner'
import { createRunner } from '../../runner.js'

export const run = createRunner(__dirname)
15 changes: 11 additions & 4 deletions packages/vscode-extension/e2e/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@ import { runTests } from '@vscode/test-electron'
import chalk from 'chalk'
import fg from 'fast-glob'
import fs from 'fs-extra'
import { projectRoot, root } from './path'
import { logger, run } from './utils'
import { projectRoot, root } from './path.js'
import { logger, run } from './utils.js'

async function main() {
const extensionDevelopmentPath = projectRoot
Expand Down Expand Up @@ -91,8 +91,15 @@ async function main() {
let fixtures: string[] = ['commonjs']
try {
const mod = await import(join(actionsDir, action, 'fixtures.js'))
const value = mod.default ?? mod
fixtures = Array.isArray(value) ? value : [value]
// Under `module: nodenext` the e2e is compiled to CommonJS, and Node's
// native ESM `import()` of a CJS module exposes `module.exports` as
// `default`, which itself carries the real `default` export. Unwrap one
// level so `export default X` resolves to `X` for both scalar and array
// fixture declarations.
let value: unknown = mod.default ?? mod
if (value && typeof value === 'object' && !Array.isArray(value) && 'default' in value)
value = (value as { default?: unknown }).default
fixtures = Array.isArray(value) ? value : [String(value)]
}
catch {
fixtures = ['commonjs']
Expand Down
5 changes: 2 additions & 3 deletions packages/vscode-extension/e2e/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,8 @@
"compilerOptions": {
"target": "esnext",
"lib": ["ESNext"],
"baseUrl": ".",
"module": "commonjs",
"moduleResolution": "node",
"module": "nodenext",
"moduleResolution": "nodenext",
"strict": true,
"outDir": "../e2e-out",
"esModuleInterop": true,
Expand Down
2 changes: 1 addition & 1 deletion packages/vscode-extension/e2e/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
import { spawn } from 'node:child_process'
import chalk from 'chalk'
import Pino from 'pino'
import { projectRoot } from './path'
import { projectRoot } from './path.js'

interface RunOptons {
cwd?: string
Expand Down
2 changes: 1 addition & 1 deletion packages/vscode-extension/ext/utils/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ export function getFileNameByPath(path: string) {
}
// Generate unique id
export function uuid() {
let dt = new Date().getTime()
let dt = Date.now()
const id = 'xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx'.replace(/[xy]/g, (c) => {
const r = (dt + Math.random() * 16) % 16 | 0
dt = Math.floor(dt / 16)
Expand Down
6 changes: 3 additions & 3 deletions packages/vscode-extension/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -177,7 +177,7 @@
"lint": "eslint .",
"lintf": "eslint . --fix",
"vscode:prepublish": "nr build",
"publish": "vsce publish --no-dependencies && ovsx publish --no-dependencies",
"publish": "ovsx publish --no-dependencies && vsce publish --no-dependencies",
"pack": "vsce package --no-dependencies",
"pack:pre": "vsce package --no-dependencies --pre-release",
"test": "vitest",
Expand All @@ -186,8 +186,8 @@
"test:unit": "vitest",
"typecheck": "vue-tsc --noEmit",
"sizecheck": "npx vite-bundle-visualizer",
"release:pre": "vsce publish --no-dependencies --pre-release && ovsx publish --no-dependencies --pre-release",
"release": "vsce publish --no-dependencies && ovsx publish --no-dependencies"
"release:pre": "ovsx publish --no-dependencies --pre-release && vsce publish --no-dependencies --pre-release",
"release": "ovsx publish --no-dependencies && vsce publish --no-dependencies"
},
"dependencies": {
"@unhead/vue": "catalog:frontend",
Expand Down
2 changes: 1 addition & 1 deletion packages/vscode-extension/src/hooks/use-handlers.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import type { DataType, HandlersType, MessageType } from '#/handlers'
import type { MessageReceiver, MessageSender } from '@jsonrpc-rx/client'
import type { DataType, HandlersType, MessageType } from '#/handlers'
import { JsonrpcClient, wrap } from '@jsonrpc-rx/client'
import { getVscodeApi } from '~/utils/vscode'

Expand Down
2 changes: 1 addition & 1 deletion packages/worma/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@
],
"scripts": {
"test": "vitest run",
"build": "run-s build:*",
"build": "run-s \"build:*\"",
"build:ts": "tsc --build tsconfig.build.json && tsc-alias -p tsconfig.build.json",
"build:dts": "dts-bundle-generator -o typings/index.d.ts src/index.ts --no-check --no-banner --project tsconfig.dts.json",
"build:plugin-dts": "dts-bundle-generator -o typings/plugins.d.ts src/plugins/index.ts --no-check --no-banner --project tsconfig.dts.json",
Expand Down
Original file line number Diff line number Diff line change
@@ -1 +1 @@
export declare function {{{name}}}<Config extends Alova2MethodConfig<{{addNamespace response @root.componentNames}}> & {{{name}}}ExtraConfig>(config: Config): Alova2Method<ExtractResponded<Config, '{{{name}}}', {{addNamespace response @root.componentNames}}>>;
export declare function {{{name}}}<Config extends Alova2MethodConfig<{{addNamespace response @root.componentNames}}> & {{{name}}}ExtraConfig>(config{{#or pathParameters queryParameters requestBody }}{{else}}?{{/or}}: Config): Alova2Method<ExtractResponded<Config, '{{{name}}}', {{addNamespace response @root.componentNames}}>>;
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ interface {{{name}}}ExtraConfig {
{{/if}}
}
{{> api-jsdoc}}
export function {{{name}}}<Config extends Alova2MethodConfig<{{addNamespace response @root.componentNames}}> & {{{name}}}ExtraConfig>(config: Config): Alova2Method<ExtractResponded<Config, '{{{name}}}', {{addNamespace response @root.componentNames}}>> {
export function {{{name}}}<Config extends Alova2MethodConfig<{{addNamespace response @root.componentNames}}> & {{{name}}}ExtraConfig>(config{{#or pathParameters queryParameters requestBody }}{{else}}?{{/or}}: Config): Alova2Method<ExtractResponded<Config, '{{{name}}}', {{addNamespace response @root.componentNames}}>> {
const { url, data, mergedConfig } = buildPayload('{{{path}}}', {{{tag}}}DefaultConfig, {{{name}}}.name, config);
return alovaInstance.Request<ExtractResponded<Config, '{{{name}}}', {{addNamespace response @root.componentNames}}>>({
...mergedConfig,
Expand Down
Original file line number Diff line number Diff line change
@@ -1 +1 @@
export declare function {{{name}}}(config: {{{name}}}ExtraConfig): Promise<{{{name}}}Response>;
export declare function {{{name}}}(config{{#or pathParameters queryParameters requestBody }}{{else}}?{{/or}}: {{{name}}}ExtraConfig): Promise<{{{name}}}Response>;
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ type {{{name}}}ExtraConfig = Omit<AxiosRequestConfig, 'data' | 'params'> & {
{{/if}}
};
{{> api-jsdoc}}
export function {{{name}}}(config: {{{name}}}ExtraConfig): Promise<{{{name}}}Response> {
export function {{{name}}}(config{{#or pathParameters queryParameters requestBody }}{{else}}?{{/or}}: {{{name}}}ExtraConfig): Promise<{{{name}}}Response> {
const { url, mergedConfig } = buildPayload('{{{path}}}', {{{tag}}}DefaultConfig, {{{name}}}.name, config);
return axiosInstance<{{{name}}}Response>({
method: '{{method}}',
Expand Down
Original file line number Diff line number Diff line change
@@ -1 +1 @@
export declare function {{{name}}}(config: {{{name}}}ExtraConfig): Promise<{{{name}}}Response>;
export declare function {{{name}}}(config{{#or pathParameters queryParameters requestBody }}{{else}}?{{/or}}: {{{name}}}ExtraConfig): Promise<{{{name}}}Response>;
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ type {{{name}}}ExtraConfig = Omit<RequestInit, 'body'> & {
{{/if}}
};
{{> api-jsdoc}}
export async function {{{name}}}(config: {{{name}}}ExtraConfig): Promise<{{{name}}}Response> {
export async function {{{name}}}(config{{#or pathParameters queryParameters requestBody }}{{else}}?{{/or}}: {{{name}}}ExtraConfig): Promise<{{{name}}}Response> {
const { url, mergedConfig } = buildPayload('{{{path}}}', {{{tag}}}DefaultConfig, {{{name}}}.name, config);
return fetchClient.request(url, { method: '{{method}}', ...mergedConfig{{#if (eq response "Blob")}}, blob: true{{/if}} }) as Promise<{{{name}}}Response>;
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1 +1 @@
export declare function {{{name}}}(config: {{{name}}}ExtraConfig): Promise<{{{name}}}Response>;
export declare function {{{name}}}(config{{#or pathParameters queryParameters requestBody }}{{else}}?{{/or}}: {{{name}}}ExtraConfig): Promise<{{{name}}}Response>;
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ type {{{name}}}ExtraConfig = Options & {
{{/if}}
};
{{> api-jsdoc}}
export function {{{name}}}(config: {{{name}}}ExtraConfig): Promise<{{{name}}}Response> {
export function {{{name}}}(config{{#or pathParameters queryParameters requestBody }}{{else}}?{{/or}}: {{{name}}}ExtraConfig): Promise<{{{name}}}Response> {
const { url, mergedConfig } = buildPayload('{{{path}}}', {{{tag}}}DefaultConfig, {{{name}}}.name, config);
const resolvedPath = url.replace(/^\//, '');
return kyInstance(resolvedPath, {
Expand Down
Loading
Loading