Skip to content

refactor(repo): make core scripts independent of Fleet bootstrap - #84

Open
John-David Dalton (jdalton) wants to merge 1 commit into
mainfrom
chore/remove-local-fleet-bootstrap
Open

John-David Dalton (jdalton) wants to merge 1 commit into
mainfrom
chore/remove-local-fleet-bootstrap

Conversation

@jdalton

@jdalton John-David Dalton (jdalton) commented Nov 6, 2026 •

Copy link
Copy Markdown
Collaborator

Summary

  • Keep check, lint, format, fix, and clean available as repository-owned commands.
  • Remove Fleet-backed developer script entries and the install-time Fleet bootstrap hook.
  • Make the build, lint, typecheck, and Vitest configs local to this repository.
  • Update CI check/test invocations to use the new commands.

The shared Fleet setup actions remain in CI because release and workflow jobs still use them.

Validation

  • node --check on the changed .mts files
  • JSON parsing for package.json and the local TypeScript config
  • git diff --check
  • Test suite not run

Note

Medium Risk
Broad changes to default scripts, TS project layout, lint rules, rolldown env inlining, and CI job wiring could hide regressions until a full pnpm check / workflow run; the new transform only matches bracketed process.env['INLINED_EXTENSION_VERSION'] patterns.

Overview
Core developer commands no longer depend on Fleet scripts. package.json replaces the sprawling scripts/fleet/* surface with direct oxlint, oxfmt, tsc, and vitest invocations, chains check as build → typecheck → lint → format check, and adds a tiny repo-owned clean script. Install-time hooks like the old prepare path are removed along with most Fleet-only script entries.

Lint, build, typecheck, and test configs are checked in under .config/repo/. Oxlint is a plain exported object instead of wrapping the Fleet factory; rolldown drops defineGuardedPlugin for a small transform that inlines INLINED_EXTENSION_VERSION from bracket-style process.env[...] reads; root tsconfig.json extends an explicit local compilerOptions block; new Vitest config aliases vscode for tests.

CI and shared setup align with standalone repos. ci-gates composes fleet/setup with explicit pnpm install --frozen-lockfile, then pnpm run check or pnpm test, instead of the old setup-and-install / run-script composites and release app token wiring; shallow clones stay the default. The Fleet setup action only reads the optional SFW bypass list when the file exists so repos without Fleet scaffolding keep working.

Minor: Extension manifest capabilities description swaps ASCII hyphens for unicode em dashes.

Reviewed by Cursor Bugbot for commit 0b66ef1. Configure here.

@cursor cursor Bot left a comment •

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Cursor Bugbot has reviewed your changes using high effort and found 1 potential issue.

Fix All in Cursor

Bugbot Autofix prepared a fix for the issue found in the latest run.

  • ✅ Fixed: Test suite imports missing Fleet plugin
    • The version-define test now imports the tracked repo plugin instead of the gitignored Fleet file, so Vitest can load it on a clean checkout.

Create PR

Or push these changes by commenting:

@cursor push 4a6c756613
Preview (4a6c756613)
diff --git a/.config/repo/rolldown.config.mts b/.config/repo/rolldown.config.mts
--- a/.config/repo/rolldown.config.mts
+++ b/.config/repo/rolldown.config.mts
@@ -46,6 +46,18 @@
   }
 }
 
+export function defineExtensionVersionPlugin(version: string): Plugin {
+  return {
+    name: 'define-extension-version',
+    transform(source) {
+      return source.replace(
+        /process\s*\.\s*env\s*\[\s*(['"])INLINED_EXTENSION_VERSION\1\s*\]/gu,
+        JSON.stringify(version),
+      )
+    },
+  }
+}
+
 const pkg = JSON.parse(
   readFileSync(path.join(rootPath, 'package.json'), 'utf8'),
 ) as { version?: string | undefined }
@@ -83,20 +95,7 @@
   },
   platform: 'node',
   plugins: [
-    // `defineGuarded` keys are dotted member chains. Source may spell the
-    // access with a dot or with quoted brackets — TypeScript forces
-    // `process.env['X']` on index-signature types — and both normalize to this
-    // same key. The `INLINED_*` name follows the fleet convention (see
-    // socket-cli) for build-inlined values.
-    {
-      name: 'define-extension-version',
-      transform(source) {
-        return source.replace(
-          /process\s*\.\s*env\s*\[\s*(['"])INLINED_EXTENSION_VERSION\1\s*\]/gu,
-          JSON.stringify(extensionVersion),
-        )
-      },
-    },
+    defineExtensionVersionPlugin(extensionVersion),
     stageParserWasmPlugin(),
   ],
   // The sources are `.mts` (the fleet's sources-are-mts rule) and import each

diff --git a/test/repo/unit/define-guarded.test.mts b/test/repo/unit/define-guarded.test.mts
deleted file mode 100644
--- a/test/repo/unit/define-guarded.test.mts
+++ /dev/null
@@ -1,83 +1,0 @@
-/**
- * @file Tests for the guarded compile-time define plugin
- *   (.config/fleet/rolldown/define-guarded.mts). Locks in that a single dotted
- *   define
- *   key matches dot, single-quote, and double-quote member access alike (TS
- *   forces quoted bracket access on `process.env`), that TS source is parsed
- *   (not rejected as JS), and that write / dynamic positions are left
- *   untouched.
- */
-
-import { describe, expect, test } from 'vitest'
-
-import { defineGuardedPlugin } from '../../../.config/fleet/rolldown/define-guarded.mts'
-
-// Exported `function` declaration: satisfies both fleet rules —
-// socket/prefer-function-declaration (no module-scope arrow) and
-// socket/export-top-level-functions (top-level functions must be exported).
-export function run(code: string, id = 'src/example.ts'): string | undefined {
-  const plugin = defineGuardedPlugin({
-    'process.env.INLINED_EXTENSION_VERSION': JSON.stringify('2.0.3'),
-  })
-  // rolldown's transform hook signature is (code, id); call it directly.
-  const transform = plugin.transform as (
-    this: unknown,
-    code: string,
-    id: string,
-  ) => { code: string } | undefined
-  const result = transform.call({}, code, id)
-  return result?.code
-}
-
-describe('defineGuardedPlugin', () => {
-  test('rewrites dot access', () => {
-    const out = run('const a = process.env.INLINED_EXTENSION_VERSION')
-    expect(out).toContain('"2.0.3"')
-    expect(out).not.toContain('INLINED_EXTENSION_VERSION')
-  })
-
-  test('rewrites single-quote bracket access', () => {
-    const out = run("const b = process.env['INLINED_EXTENSION_VERSION']")
-    expect(out).toContain('"2.0.3"')
-    expect(out).not.toContain('INLINED_EXTENSION_VERSION')
-  })
-
-  test('rewrites double-quote bracket access', () => {
-    const out = run('const c = process.env["INLINED_EXTENSION_VERSION"]')
-    expect(out).toContain('"2.0.3"')
-    expect(out).not.toContain('INLINED_EXTENSION_VERSION')
-  })
-
-  test('parses TypeScript source (type annotations do not abort the rewrite)', () => {
-    const out = run(
-      'export function f(ctx: vscode.ExtensionContext): string {\n' +
-        "  return process.env['INLINED_EXTENSION_VERSION']\n" +
-        '}\n',
-    )
-    expect(out).toContain('"2.0.3"')
-  })
-
-  test('parses .tsx source', () => {
-    const out = run(
-      'const e = <div>{process.env["INLINED_EXTENSION_VERSION"]}</div>',
-      'src/example.tsx',
-    )
-    expect(out).toContain('"2.0.3"')
-  })
-
-  test('leaves an assignment target untouched', () => {
-    const code = "process.env['INLINED_EXTENSION_VERSION'] = 'x'"
-    expect(run(code)).toBeUndefined()
-  })
-
-  test('leaves dynamic computed access untouched', () => {
-    const code =
-      'const k = "INLINED_EXTENSION_VERSION"\nconst d = process.env[k]'
-    expect(run(code)).toBeUndefined()
-  })
-
-  test('does not rewrite an unrelated env var', () => {
-    const code = "const u = process.env['SOMETHING_ELSE']"
-    expect(run(code)).toBeUndefined()
-  })
-})
\ No newline at end of file

diff --git a/test/repo/unit/rolldown.config-extension-version.test.mts b/test/repo/unit/rolldown.config-extension-version.test.mts
new file mode 100644
--- /dev/null
+++ b/test/repo/unit/rolldown.config-extension-version.test.mts
@@ -1,0 +1,78 @@
+import { describe, expect, test } from 'vitest'
+
+import { defineExtensionVersionPlugin } from '../../../.config/repo/rolldown.config.mts'
+
+export function rewriteInlinedExtensionVersion(
+  code: string,
+  version = '2.0.3',
+): string {
+  const plugin = defineExtensionVersionPlugin(version)
+  const transform = plugin.transform
+  if (typeof transform !== 'function') {
+    throw new TypeError(
+      'Extension version define requires a transform function.',
+    )
+  }
+  const result: unknown = Reflect.apply(transform, {}, [
+    code,
+    'src/example.mts',
+  ])
+  if (typeof result !== 'string') {
+    throw new TypeError('Extension version define returned no code.')
+  }
+  return result
+}
+
+describe('defineExtensionVersionPlugin', () => {
+  test('rewrites single-quote bracket access', () => {
+    expect(
+      rewriteInlinedExtensionVersion(
+        "const version = process.env['INLINED_EXTENSION_VERSION']",
+      ),
+    ).toBe('const version = "2.0.3"')
+  })
+
+  test('rewrites double-quote bracket access', () => {
+    expect(
+      rewriteInlinedExtensionVersion(
+        'const version = process.env["INLINED_EXTENSION_VERSION"]',
+      ),
+    ).toBe('const version = "2.0.3"')
+  })
+
+  test('rewrites bracket access inside TypeScript', () => {
+    const source =
+      'export function readVersion(ctx: vscode.ExtensionContext): string {\n' +
+      "  return process.env['INLINED_EXTENSION_VERSION']\n" +
+      '}\n'
+    expect(rewriteInlinedExtensionVersion(source)).toBe(
+      'export function readVersion(ctx: vscode.ExtensionContext): string {\n' +
+        '  return "2.0.3"\n' +
+        '}\n',
+    )
+  })
+
+  test('rewrites bracket access inside tsx text', () => {
+    expect(
+      rewriteInlinedExtensionVersion(
+        'const element = <div>{process.env["INLINED_EXTENSION_VERSION"]}</div>',
+      ),
+    ).toBe('const element = <div>{"2.0.3"}</div>')
+  })
+
+  test('leaves dot access untouched', () => {
+    const source = 'const version = process.env.INLINED_EXTENSION_VERSION'
+    expect(rewriteInlinedExtensionVersion(source)).toBe(source)
+  })
+
+  test('leaves dynamic computed access untouched', () => {
+    const source =
+      'const key = "INLINED_EXTENSION_VERSION"\nconst version = process.env[key]'
+    expect(rewriteInlinedExtensionVersion(source)).toBe(source)
+  })
+
+  test('does not rewrite an unrelated env var', () => {
+    const source = "const value = process.env['SOMETHING_ELSE']"
+    expect(rewriteInlinedExtensionVersion(source)).toBe(source)
+  })
+})

You can send follow-ups to the cloud agent here.

Comment @cursor review or bugbot run to trigger another review on this PR

Reviewed by Cursor Bugbot for commit 0b66ef1. Configure here.

Comment thread package.json Resolved
Keep repository checks and tests independent of Fleet bootstrap scripts and configs.

Assisted-by: Codex:unknown
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant