Skip to content

chore: migrate code-snippet - #616

Merged
jacob-kreyenbuehl merged 24 commits into
mainfrom
migration/code-snippet
Sep 24, 2026
Merged

jacob-kreyenbuehl merged 24 commits into
mainfrom
migration/code-snippet

Conversation

@jacob-kreyenbuehl

Copy link
Copy Markdown
Contributor

Summary

Migrates the Code Snippet framework from SAP/code-snippet into the app-studio-toolkit monorepo under projects/code-snippet.

Key changes

  • Adds the public @sap-devx/code-snippet-types package plus private backend, frontend, wrapper, and example workspaces.
  • Wires the backend and frontend as workspace build dependencies and adds the backend's missing runtime dependencies.
  • Adds the fixed/ignore changeset configuration, legacy TypeScript and ESLint compatibility, pnpm-safe VSIX packaging, and monorepo metadata.
  • Preserves historic changelogs as CHANGELOG.old.md and updates project documentation and package links.

Behaviour

No changeset is included because this is a relocation-only migration. The maintenance-release changeset will be created after this PR merges. Scoped package CI, Prettier, and ESLint are green.

Reviewer's guide

95 files changed, but most are a source lift. Review in this order:

  1. Release wiring: .changeset/config.json, workspace discovery, package metadata, and the public types package.
  2. Build and lint configuration: tsconfig.base.json, root ESLint override, nyc/mocha scripts, webpack, and VSIX ignore files.
  3. Dependency wiring: backend runtime dependencies and the frontend/types workspace:* relationships.
  4. Everything else: skim as a formatted source migration.

Not in this PR (deliberately): no changeset or release/version bump. @sap-devx/code-snippet-types already exists on npm at 2.0.0; its maintenance release must be handled in the post-merge changeset PR.

Signed-off-by: Jacob Kreyenbuehl <jacob.kreyenbuehl@sap.com>
Signed-off-by: Jacob Kreyenbuehl <jacob.kreyenbuehl@sap.com>
Signed-off-by: Jacob Kreyenbuehl <jacob.kreyenbuehl@sap.com>
Signed-off-by: Jacob Kreyenbuehl <jacob.kreyenbuehl@sap.com>
Signed-off-by: Jacob Kreyenbuehl <jacob.kreyenbuehl@sap.com>
Signed-off-by: Jacob Kreyenbuehl <jacob.kreyenbuehl@sap.com>
Signed-off-by: Jacob Kreyenbuehl <jacob.kreyenbuehl@sap.com>
Signed-off-by: Jacob Kreyenbuehl <jacob.kreyenbuehl@sap.com>
# Conflicts:
#	.changeset/config.json
#	pnpm-lock.yaml
… and jest globals

The frontend was migrated without an eslint config, so the monorepo root
lint flagged App.vue (acquireVsCodeApi is undefined), the ESM .js files
(import/export needed sourceType module) and the jest test globals.
Add a package level .eslintrc.js that declares the webview global, sets
sourceType module with a modern ecmaVersion, enables the jest env for
tests, and keeps the legacy single-word component name. Matches the
task-explorer frontend approach.

Signed-off-by: Jacob Kreyenbuehl <jacob.kreyenbuehl@sap.com>
…ce break

Merging main and regenerating the lockfile re-bound vuetify to vue@3.4.3
(task-explorer's vue_frontend_rpc pins it), which breaks inquirer-gui's
plugin tests with 'app.onUnmount is not a function' (a Vue 3.5 API).
Pin vue workspace-wide so only one version resolves. Same fix as the
cloud-foundry-tools migration.

Signed-off-by: Jacob Kreyenbuehl <jacob.kreyenbuehl@sap.com>
The migration added a bare yeoman-generator@4.12.0 dependency. The
standalone repo used the module without declaring it, relying on flat
node_modules hoisting. In pnpm's isolated layout that pin changed which
yeoman-generator version is hoisted to node_modules/.pnpm/node_modules,
and yeoman-env-v3's webpack bundle resolves yeoman-environment@3.19.3's
undeclared require('yeoman-generator') through that hoist. With 4.12.0
hoisted the bundle pulled in istextorbinary@2.6.0 -> editions@2.3.1 ->
errlop@2.2.0/edition-browsers (ESM mis-parsed as CJS), failing the
yeoman-env-v3 build. On main the hoist is yeoman-generator@8.2.2 and the
bundle is clean.

code-snippet only uses Generator as a type (code-snippet.ts:23) and the
package is not in the emitted bundle, so no runtime dependency is needed.
Removing it restores main's hoist decision. Keep @types/yeoman-generator
so Generator resolves to a real type; without it eslint's
no-redundant-type-constituents fires on `Generator | undefined`.

Verified locally on Node 24: eslint clean, tsc clean, 50 tests pass,
backend bundle clean and free of yeoman-generator, and yeoman-env-v3
compiles with the same 6 warnings as main.

Signed-off-by: Jacob Kreyenbuehl <jacob.kreyenbuehl@sap.com>
# Conflicts:
#	.changeset/config.json
#	pnpm-lock.yaml
Adding the code-snippet packages makes pnpm resolve @types/vscode afresh
for two third-party type packages:

  @sap-devx/code-snippet-types       @types/vscode: ^1.48.0
  @sap/artifact-management-base-types @types/vscode: >=1.52.0 < 2.0.0

Both loose ranges now pick 1.138.0 instead of the 1.75.0 the repository
already uses. Two @types/vscode copies then land in
app-studio-toolkit-types' program and its compile fails with TS6200
(duplicate identifiers), TS2374 and TS2717.

Main never hit this because its lockfile already binds those two to
1.75.0 and pnpm install does not re-resolve existing entries. Scoped
overrides keep that binding stable for any future install too.

Verified locally: app-studio-toolkit-types compiles, eslint clean,
yeoman-env-v3 bundle compiles with the same 6 warnings as main, and the
lockfile passes --frozen-lockfile.

Signed-off-by: Jacob Kreyenbuehl <jacob.kreyenbuehl@sap.com>
The migration copied the source's thresholds (lines 99, statements 99,
branches 98, functions 97) but also changed temp-dir from
./reports/.nyc_output to ./.nyc_output. Two consequences:

- the package dropped into the default .nyc_output, which the root
  merged-coverage gate globs;
- its own thresholds are unreachable here (nyc 15 accounting on the same
  tests gives 94.67 lines / 92.13 statements / 78.72 branches /
  87.93 functions), so its own check failed.

This matches the pattern the playbook prescribes for VS Code extension
backends, as done in PR #624: redirect the package's nyc output to
./reports/.nyc_output and keep realistic thresholds it enforces itself.

Verified locally on Node 24: coverage passes, bundle clean, 50 tests.

Signed-off-by: Jacob Kreyenbuehl <jacob.kreyenbuehl@sap.com>
The source pinned the deprecated vsce@1.x with 'vsce package --yarn',
which shells out to yarn and does not exist in this pnpm monorepo. The
migration only swapped the flag to --no-yarn, so 'vsce package' still
failed on 'npm list --production' in the workspace.

Use the monorepo standard from the playbook (and PR #624): depend on
@vscode/vsce 2.24.0 and run 'vsce package --no-dependencies'. The
extension is webpack-bundled, so vsce does not need to walk runtime deps.

Verified locally on Node 24: the package's full ci now completes
(compile, coverage, bundle, frontend:copy, package, coverage:copy).

Signed-off-by: Jacob Kreyenbuehl <jacob.kreyenbuehl@sap.com>
@github-actions

github-actions Bot commented Sep 23, 2026 •

Copy link
Copy Markdown
Contributor

Build Report

badge

Please note:

  1. Files only stay for around 14 days!
  2. This comment will be updated with the data of the last successful build of this PR.
Name Link
Commit ff87ac3
Logs https://github.com/SAP/app-studio-toolkit/actions/runs/35975307935
VSIX Files https://github.com/SAP/app-studio-toolkit/actions/runs/35975307935/artifacts/10798008162

Comment thread projects/code-snippet/packages/frontend/jest.config.js Outdated
Comment thread projects/code-snippet/packages/wrapper/package.json Outdated
Comment thread projects/code-snippet/packages/wrapper/.nycrc.json Outdated
Comment thread projects/code-snippet/packages/types/README.md Outdated
Comment thread projects/code-snippet/packages/types/README.md Outdated
Comment thread projects/code-snippet/packages/frontend/.eslintrc.js
Comment thread projects/code-snippet/packages/backend/README.md Outdated
Comment thread projects/code-snippet/packages/frontend/README.md Outdated
Comment thread projects/code-snippet/packages/backend/CHANGELOG.md Outdated
Comment thread projects/code-snippet/CHANGELOG.old.md
…jest config

The flat <rootDir>/node_modules form matches nothing under pnpm, where
dependencies resolve into <workspaceRoot>/node_modules/.pnpm, so nothing
was being scoped deliberately. Use the .pnpm allow-list form like the
other migrated frontends, covering the ESM deps this package pulls
(@sap-devx/*, vuetify, lodash).

Verified: 17 tests pass, same as before the change.
Signed-off-by: Jacob Kreyenbuehl <jacob.kreyenbuehl@sap.com>
The frontend had both .eslintrc.js and a package.json eslintConfig.
ESLint uses the .eslintrc.js, so the package.json block was dead:
--print-config showed its env (vue/setup-compiler-macros) was not applied.
The root .eslintrc.js already extends plugin:vue/vue3-essential for .vue
files, so nothing is lost.

Verified: repo-wide eslint --max-warnings=0 is clean.
Signed-off-by: Jacob Kreyenbuehl <jacob.kreyenbuehl@sap.com>
The wrapper still used the deprecated vsce@^1.x with 'package --no-yarn'
and wrote coverage to the default ./.nyc_output, which the root
merge-coverage globs into the 100% gate. Align it with the backend and
with PR #624: @vscode/vsce 2.24.0 + 'vsce package --no-dependencies', and
redirect nyc output to ./reports/.nyc_output.

Verified: the wrapper's full ci passes (2 tests, 100% coverage, bundle,
vsce package, coverage:copy).

Signed-off-by: Jacob Kreyenbuehl <jacob.kreyenbuehl@sap.com>
- backend README preview image and frontend README inquirer-gui link
  pointed at the retired standalone repos
- types README linked SAP/code-snippet issues and a ./CONTRIBUTING.md
  that does not exist in that package
- all four package CHANGELOG.md files were headed with the folder name;
  changesets writes the package name

Signed-off-by: Jacob Kreyenbuehl <jacob.kreyenbuehl@sap.com>
…eview

Fidelity reverts to source (migration stays faithful):
- backend + wrapper webpack.config.js: restore node.global=true. It is a
  no-op under target:node (global exists in the VS Code host), but the
  source and the already-migrated yeoman-ui/guided-development backends
  keep it.
- backend + wrapper .vscodeignore: restore the source contents. The
  migration-added parent-dir excludes change nothing (vsix contents are
  byte-identical with and without them, verified by packaging both ways)

Findings from the independent review that were in scope:
- example vscode-snippet-contrib: package script used the deprecated
  vsce 1.x with --no-yarn and did not even declare it, so it failed if
  run; now on @vscode/vsce 2.24.0 with --no-dependencies like the rest.
- frontend: removed the dead 'lint' script (vue-cli-service is not a
  dependency here; the same dead script existed in the source repo too).

Out of scope (pre-existing in the source repo, byte-identical, so the
migration stays faithful): the properties.push TypeError in
usage-analytics-wrapper.ts, the un-awaited initHtmlContent in
AbstractWebviewPanel.ts, the per-extension log spam in contributors.ts,
and the duplicate coverage step in backend ci.
@jacob-kreyenbuehl
jacob-kreyenbuehl merged commit b87f540 into main Sep 24, 2026
4 checks passed
@jacob-kreyenbuehl
jacob-kreyenbuehl deleted the migration/code-snippet branch September 24, 2026 08:53
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.

2 participants