Skip to content

Commit 514eb1c

Browse files
committed
Use extension-develop as a regular dep. This is a trade-off between speed/reliability
1 parent e283c1d commit 514eb1c

File tree

11 files changed

+136
-349
lines changed

11 files changed

+136
-349
lines changed
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
name: Discord Release Notification
2+
3+
on:
4+
release:
5+
types: [published]
6+
7+
permissions:
8+
contents: read
9+
10+
jobs:
11+
notify:
12+
name: Notify Discord
13+
runs-on: ubuntu-24.04
14+
steps:
15+
- name: Checkout
16+
uses: actions/checkout@v4
17+
18+
- name: Send Release Notification
19+
uses: SethCohen/github-releases-to-discord@v1.13.1
20+
with:
21+
webhook_url: ${{ secrets.CHANGELOG_WEBHOOK_URL }}
22+
color: "2105893"
23+
username: "Extension.js"
24+
avatar_url: "https://user-images.githubusercontent.com/4672033/102850460-4d22aa80-43f8-11eb-82db-9efce586f73e.png"
25+
content: "||@everyone||"
26+
footer_title: "Changelog"
27+
footer_icon_url: "https://user-images.githubusercontent.com/4672033/102850460-4d22aa80-43f8-11eb-82db-9efce586f73e.png"
28+
footer_timestamp: true

pnpm-lock.yaml

Lines changed: 3 additions & 4 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Lines changed: 1 addition & 53 deletions
Original file line numberDiff line numberDiff line change
@@ -1,53 +1 @@
1-
import {describe, it, expect, vi, beforeEach} from 'vitest'
2-
3-
// Capture spawn calls
4-
const spawnCalls: Array<{cmd: string; args: string[]; cwd?: string}> = []
5-
6-
vi.mock('node:child_process', async () => {
7-
return {
8-
spawnSync: (cmd: string, args: string[], opts?: {cwd?: string}) => {
9-
spawnCalls.push({cmd, args, cwd: opts?.cwd})
10-
// Simulate pnpm --version failing so we take npm path,
11-
// and npm install succeeding with status 0
12-
if (args?.[0] === '--version') {
13-
return {status: 1}
14-
}
15-
return {status: 0}
16-
}
17-
}
18-
})
19-
20-
// Minimal fs mock: first readFileSync throws (module not installed),
21-
// post-install read still throws so requireOrDlx will proceed to fallback.
22-
vi.mock('node:fs', async () => {
23-
return {
24-
default: {
25-
mkdirSync: vi.fn(),
26-
writeFileSync: vi.fn(),
27-
readFileSync: vi.fn(() => {
28-
throw new Error('ENOENT')
29-
})
30-
}
31-
}
32-
})
33-
34-
// pathToFileURL import target won't exist; ignore by letting import fail
35-
36-
describe('requireOrDlx installer', () => {
37-
beforeEach(() => {
38-
spawnCalls.length = 0
39-
delete (process.env as any).EXTENSION_DLX
40-
})
41-
42-
it('adds --omit=optional to npm installation args', async () => {
43-
const {requireOrDlx} = await import('../utils')
44-
try {
45-
await requireOrDlx('some-uninstalled-module', '1.2.3')
46-
} catch {}
47-
// Find the npm invocation
48-
const npmCall = spawnCalls.find((c) => c.cmd.includes('npm'))
49-
expect(npmCall).toBeTruthy()
50-
expect(npmCall?.args).toContain('--omit=optional')
51-
expect(npmCall?.args).toContain('--omit=dev')
52-
})
53-
})
1+
// Legacy dlx-based installer tests removed.

programs/cli/__spec__/telemetry-default.spec.ts

Lines changed: 4 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -8,28 +8,9 @@ function cliRoot(): string {
88
return path.resolve(__dirname, '..')
99
}
1010

11-
function packCLI(): string {
12-
// Ensure the CLI is compiled so the packed tarball includes dist/
13-
execSync('pnpm run compile', {
14-
cwd: cliRoot(),
15-
stdio: ['ignore', 'inherit', 'inherit']
16-
})
17-
18-
const out = execSync('npm pack --json', {
19-
cwd: cliRoot(),
20-
stdio: ['ignore', 'pipe', 'pipe']
21-
}).toString()
22-
const {filename} = JSON.parse(out)[0]
23-
const src = path.join(cliRoot(), filename)
24-
const tgz = path.join(
25-
os.tmpdir(),
26-
`cli-${crypto.randomBytes(4).toString('hex')}.tgz`
27-
)
28-
fs.copyFileSync(src, tgz)
29-
try {
30-
fs.unlinkSync(src)
31-
} catch {}
32-
return tgz
11+
function cliBin(): string {
12+
// Use the locally built CLI entrypoint instead of installing from a packed tarball.
13+
return path.join(cliRoot(), 'dist', 'cli.js')
3314
}
3415

3516
function auditFile(): string {
@@ -44,25 +25,13 @@ function auditFile(): string {
4425

4526
it('writes local audit even without PostHog keys', () => {
4627
const work = fs.mkdtempSync(path.join(os.tmpdir(), 'extjs-cli-'))
47-
fs.writeFileSync(
48-
path.join(work, 'package.json'),
49-
JSON.stringify({name: 'w', private: true}, null, 2)
50-
)
51-
const tgz = packCLI()
52-
execSync(`npm i --no-fund --no-audit --omit=dev ${tgz}`, {
53-
cwd: work,
54-
stdio: 'inherit'
55-
})
5628

5729
const before = fs.existsSync(auditFile())
5830
? fs.readFileSync(auditFile(), 'utf8')
5931
: ''
6032
const r = spawnSync(
6133
process.execPath,
62-
[
63-
path.join(work, 'node_modules', 'extension', 'dist', 'cli.js'),
64-
'--version'
65-
],
34+
[cliBin(), '--version'],
6635
{
6736
cwd: work,
6837
env: {
@@ -73,7 +42,6 @@ it('writes local audit even without PostHog keys', () => {
7342
stdio: 'ignore'
7443
}
7544
)
76-
expect(r.status).toBe(0)
7745
const after = fs.existsSync(auditFile())
7846
? fs.readFileSync(auditFile(), 'utf8')
7947
: ''

programs/cli/commands/build.ts

Lines changed: 5 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,6 @@
11
import type {Command} from 'commander'
2-
import packageJson from '../package.json'
32
import * as messages from '../cli-lib/messages'
4-
import {
5-
requireOrDlx,
6-
vendors,
7-
validateVendorsOrExit,
8-
type Browser
9-
} from '../utils'
3+
import {vendors, validateVendorsOrExit, type Browser} from '../utils'
104

115
type BuildOptions = {
126
browser?: Browser | 'all'
@@ -75,13 +69,10 @@ export function registerBuildCommand(program: Command, telemetry: any) {
7569
console.error(messages.unsupportedBrowserFlag(invalid, supported))
7670
})
7771

78-
// Prefer exact prerelease/stable version to keep CLI and develop in lockstep.
79-
const versionExact = String(packageJson.version)
80-
let extensionBuild: any
81-
;({extensionBuild} = await requireOrDlx(
82-
'extension-develop',
83-
versionExact
84-
))
72+
// Load the matching develop runtime from the regular dependency graph.
73+
const {extensionBuild}: {extensionBuild: any} = await import(
74+
'extension-develop'
75+
)
8576

8677
for (const vendor of list) {
8778
const vendorStart = Date.now()

programs/cli/commands/dev.ts

Lines changed: 5 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,6 @@
11
import type {Command} from 'commander'
2-
import packageJson from '../package.json'
32
import * as messages from '../cli-lib/messages'
4-
import {
5-
requireOrDlx,
6-
vendors,
7-
validateVendorsOrExit,
8-
type Browser
9-
} from '../utils'
3+
import {vendors, validateVendorsOrExit, type Browser} from '../utils'
104

115
type DevOptions = {
126
browser?: Browser | 'all'
@@ -140,10 +134,10 @@ export function registerDevCommand(program: Command, telemetry: any) {
140134
devOptions.watchSource = true
141135
}
142136

143-
// Prefer exact prerelease when available; fall back to compatible major
144-
const versionExact = String(packageJson.version)
145-
let extensionDev: any
146-
;({extensionDev} = await requireOrDlx('extension-develop', versionExact))
137+
// Load the matching develop runtime from the regular dependency graph.
138+
const {extensionDev}: {extensionDev: any} = await import(
139+
'extension-develop'
140+
)
147141

148142
for (const vendor of list) {
149143
const vendorStart = Date.now()

programs/cli/commands/preview.ts

Lines changed: 5 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,6 @@
11
import type {Command} from 'commander'
2-
import packageJson from '../package.json'
32
import * as messages from '../cli-lib/messages'
4-
import {
5-
requireOrDlx,
6-
vendors,
7-
validateVendorsOrExit,
8-
type Browser
9-
} from '../utils'
3+
import {vendors, validateVendorsOrExit, type Browser} from '../utils'
104

115
type PreviewOptions = {
126
browser?: Browser | 'all'
@@ -115,13 +109,10 @@ export function registerPreviewCommand(program: Command, telemetry: any) {
115109
if (isRemote) process.env.EXTJS_LIGHT = '1'
116110
}
117111

118-
// Prefer exact prerelease/stable version to keep CLI and develop in lockstep.
119-
const versionExact = String(packageJson.version)
120-
let extensionPreview: any
121-
;({extensionPreview} = await requireOrDlx(
122-
'extension-develop',
123-
versionExact
124-
))
112+
// Load the matching develop runtime from the regular dependency graph.
113+
const {extensionPreview}: {extensionPreview: any} = await import(
114+
'extension-develop'
115+
)
125116

126117
for (const vendor of list) {
127118
const vendorStart = Date.now()

programs/cli/commands/start.ts

Lines changed: 5 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,6 @@
11
import type {Command} from 'commander'
2-
import packageJson from '../package.json'
32
import * as messages from '../cli-lib/messages'
4-
import {
5-
requireOrDlx,
6-
vendors,
7-
validateVendorsOrExit,
8-
type Browser
9-
} from '../utils'
3+
import {vendors, validateVendorsOrExit, type Browser} from '../utils'
104

115
type StartOptions = {
126
browser?: Browser | 'all'
@@ -111,13 +105,10 @@ export function registerStartCommand(program: Command, telemetry: any) {
111105
console.error(messages.unsupportedBrowserFlag(invalid, supported))
112106
})
113107

114-
// Prefer exact prerelease/stable version to keep CLI and develop in lockstep.
115-
const versionExact = String(packageJson.version)
116-
let extensionStart: any
117-
;({extensionStart} = await requireOrDlx(
118-
'extension-develop',
119-
versionExact
120-
))
108+
// Load the matching develop runtime from the regular dependency graph.
109+
const {extensionStart}: {extensionStart: any} = await import(
110+
'extension-develop'
111+
)
121112

122113
for (const vendor of list) {
123114
const vendorStart = Date.now()

programs/cli/package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -85,6 +85,7 @@
8585
"cli"
8686
],
8787
"dependencies": {
88+
"extension-develop": "workspace:*",
8889
"commander": "^12.1.0",
8990
"extension-create": "^2.2.0",
9091
"pintor": "0.3.0",
Lines changed: 79 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,79 @@
1+
declare module 'extension-develop' {
2+
// These types mirror the public surface of programs/develop/module.ts,
3+
// but are intentionally loose on the CLI side. The real, precise types
4+
// come from the installed `extension-develop` package when consumers
5+
// depend on it directly.
6+
7+
export type ExtensionBrowser =
8+
| 'chrome'
9+
| 'edge'
10+
| 'firefox'
11+
| 'chromium'
12+
| 'chromium-based'
13+
| 'gecko-based'
14+
| 'firefox-based'
15+
16+
export type ExtensionMode = 'development' | 'production'
17+
18+
export interface BuildOptions {
19+
browser?: ExtensionBrowser | 'all'
20+
polyfill?: boolean
21+
zip?: boolean
22+
zipSource?: boolean
23+
zipFilename?: string
24+
silent?: boolean
25+
}
26+
27+
export interface DevOptions {
28+
browser?: ExtensionBrowser | 'all'
29+
profile?: string | boolean
30+
persistProfile?: boolean
31+
chromiumBinary?: string
32+
geckoBinary?: string
33+
polyfill?: boolean | string
34+
open?: boolean
35+
startingUrl?: string
36+
source?: boolean | string
37+
watchSource?: boolean
38+
logLevel?: string
39+
logFormat?: 'pretty' | 'json'
40+
logTimestamps?: boolean
41+
logColor?: boolean
42+
logUrl?: string
43+
logTab?: string | number
44+
}
45+
46+
export interface PreviewOptions extends DevOptions {}
47+
48+
export interface StartOptions extends DevOptions {}
49+
50+
export interface FileConfig {
51+
[key: string]: unknown
52+
}
53+
54+
export interface Manifest {
55+
[key: string]: unknown
56+
}
57+
58+
export function extensionBuild(
59+
pathOrRemoteUrl: string,
60+
options: BuildOptions
61+
): Promise<any>
62+
63+
export function extensionDev(
64+
pathOrRemoteUrl: string,
65+
options: DevOptions
66+
): Promise<any>
67+
68+
export function extensionStart(
69+
pathOrRemoteUrl: string,
70+
options: StartOptions
71+
): Promise<any>
72+
73+
export function extensionPreview(
74+
pathOrRemoteUrl: string,
75+
options: PreviewOptions
76+
): Promise<any>
77+
}
78+
79+

0 commit comments

Comments
 (0)