Skip to content

Commit 0e1a17d

Browse files
authored
refactor: extract shared files, move test files, prepare for lsp (#80)
* refactor: move test & shared files, prepare for lsp * update * update
1 parent 36abe63 commit 0e1a17d

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

45 files changed

+93
-72
lines changed

.gitignore

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
.DS_Store
22
node_modules
33
dist
4-
src/generated-meta.ts
4+
shared/meta.ts
55

66
# local env files
77
.env.local

package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -200,12 +200,12 @@
200200
"dev": "tsdown --watch",
201201
"build": "tsdown",
202202
"postinstall": "npm run update",
203-
"update": "vscode-ext-gen --scope npmx",
203+
"update": "vscode-ext-gen --scope npmx --output ./shared/meta.ts",
204204
"check": "npm run lint:fix && npm run typecheck",
205205
"test": "vitest",
206206
"lint": "eslint .",
207207
"lint:fix": "eslint . --fix",
208-
"typecheck": "tsgo --noEmit",
208+
"typecheck": "tsgo -b --noEmit",
209209
"vscode:prepublish": "npm run build",
210210
"publish": "npx @vscode/vsce publish --no-dependencies",
211211
"package": "npx @vscode/vsce package --no-dependencies",
File renamed without changes.
Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,10 @@
1-
import type { ConfigKey } from '../generated-meta'
1+
import type { ConfigKey } from './meta'
22

33
type StripPrefix<T, Prefix extends string>
44
= T extends `${Prefix}${infer Rest}`
55
? Rest
66
: never
77

88
export type DiagnosticsCode = StripPrefix<ConfigKey, 'npmx.diagnostics.'>
9+
10+
export type PackageManager = 'npm' | 'pnpm' | 'yarn'

src/api/package.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import type { MaybeError, PackageVersionsInfoWithMetadata } from 'fast-npm-meta'
2-
import { CACHE_MAX_AGE_ONE_DAY } from '#constants'
2+
import { CACHE_MAX_AGE_ONE_DAY } from '#shared/constants'
33
import { logger } from '#state'
44
import { createBatchRunner } from '#utils/batch'
55
import { getVersionsBatch } from 'fast-npm-meta'

src/api/replacement.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import type { ModuleReplacement } from 'module-replacements'
2-
import { CACHE_MAX_AGE_ONE_DAY, NPMX_DEV_API } from '#constants'
2+
import { CACHE_MAX_AGE_ONE_DAY, NPMX_DEV_API } from '#shared/constants'
33
import { logger } from '#state'
44
import { encodePackageName } from '#utils/package'
55
import { defineCachedFunction } from 'ocache'

src/api/vulnerability.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { CACHE_MAX_AGE_ONE_DAY, NPMX_DEV_API } from '#constants'
1+
import { CACHE_MAX_AGE_ONE_DAY, NPMX_DEV_API } from '#shared/constants'
22
import { logger } from '#state'
33
import { encodePackageName, formatPackageId } from '#utils/package'
44
import { defineCachedFunction } from 'ocache'

src/commands/add-to-ignore.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import type { ConfigurationTarget } from 'vscode'
2+
import { scopedConfigs } from '#shared/meta'
23
import { checkIgnored } from '#utils/ignore'
34
import { workspace } from 'vscode'
4-
import { scopedConfigs } from '../generated-meta'
55

66
export async function addToIgnore(scope: string, name: string, target: ConfigurationTarget) {
77
const ignoreScope = `ignore.${scope}`

src/commands/open-file-in-npmx.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { PACKAGE_JSON_BASENAME } from '#constants'
1+
import { PACKAGE_JSON_BASENAME } from '#shared/constants'
22
import { logger } from '#state'
33
import { readPackageManifest } from '#utils/file'
44
import { npmxFileUrl } from '#utils/links'

src/commands/open-in-browser.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { NPMX_DEV } from '#constants'
1+
import { NPMX_DEV } from '#shared/constants'
22
import { env, Uri } from 'vscode'
33

44
export function openInBrowser() {

0 commit comments

Comments
 (0)