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
8 changes: 6 additions & 2 deletions .github/workflows/pkg-publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -29,13 +29,17 @@ jobs:

- run: node --run build

- name: Publish to npm
- name: Publish npm packages
uses: changesets/action@v1
with:
publish: node --run publish-packages
publish: node --run publish:npm
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
NPM_TOKEN: ${{ secrets.NPM_TOKEN }}
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
NPM_CONFIG_PROVENANCE: 'true'

- name: Publish VS Code extensions
run: node --run publish:vscode
env:
VSCE_PAT: ${{ secrets.VSCE_TOKEN }}
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -41,3 +41,6 @@ lerna-debug.log*

# Vite
.vite

# Temporary LICENSE copies (created by publish scripts)
packages/*/LICENSE
1,075 changes: 386 additions & 689 deletions package-lock.json

Large diffs are not rendered by default.

3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,8 @@
"format": "prettier --write .",
"format:check": "prettier --check .",
"changeset": "changeset",
"publish-packages": "changeset publish",
"publish:npm": "tsx tooling/publish/publish-npm.ts",
"publish:vscode": "tsx tooling/publish/publish-vscode.ts",
"start:local-npm-registry": "npm run build && cd ./local-npm-registry && npm start",
"stop:local-npm-registry": "cd ./local-npm-registry && npm stop",
"local:publish": "node --run start:local-npm-registry && changeset version && node local-npm-registry/publish.js changeset publish",
Expand Down
8 changes: 8 additions & 0 deletions packages/vscode-extension/.vscodeignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
src/**
node_modules/**
*.ts
tsconfig.json
tsdown.config.ts
vitest.config.ts
.turbo/**
coverage/**
7 changes: 2 additions & 5 deletions packages/vscode-extension/package.json
Original file line number Diff line number Diff line change
@@ -1,14 +1,11 @@
{
"name": "@lemoncode/quickmock-vscode-extension",
"name": "quickmock",
"version": "0.0.1",
"type": "module",
"main": "./dist/index.mjs",
"imports": {
"#*": "./src/*"
},
"files": [
"dist"
],
"scripts": {
"dev": "node --run build -- --watch --sourcemap",
"build": "tsdown",
Expand Down Expand Up @@ -50,7 +47,7 @@
"directory": "packages/vscode-extension"
},
"engines": {
"vscode": "^1.105.0"
"vscode": "^1.116.0"
},
"icon": "./assets/app-icon.webp",
"galleryBanner": {
Expand Down
2 changes: 1 addition & 1 deletion tooling/dev-cli/dev.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import * as p from '@clack/prompts';
import { spawn } from 'node:child_process';
import { filterByScript, getWorkspacePackages } from './lib/workspace.ts';
import { filterByScript, getWorkspacePackages } from './lib/workspace';

const main = async () => {
p.intro('Dev CLI');
Expand Down
2 changes: 1 addition & 1 deletion tooling/dev-cli/test-watch.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import * as p from '@clack/prompts';
import { spawn } from 'node:child_process';
import { resolve } from 'node:path';
import { filterByScript, getWorkspacePackages } from './lib/workspace.ts';
import { filterByScript, getWorkspacePackages } from './lib/workspace';

const ROOT = resolve(import.meta.dirname, '../..');

Expand Down
5 changes: 5 additions & 0 deletions tooling/publish/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"name": "publish",
"type": "module",
"private": true
}
42 changes: 42 additions & 0 deletions tooling/publish/publish-npm.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
import { execSync, type ExecSyncOptions } from 'node:child_process';
import { readFile, writeFile } from 'node:fs/promises';
import { resolve } from 'node:path';
import { ROOT, VSCODE_EXTENSION_PATHS } from './publish.constants';

interface PackageJson {
private?: boolean;
[key: string]: unknown;
}

const markAsPrivate = async (
pkgPath: string
): Promise<{ path: string; original: string }> => {
const fullPath = resolve(ROOT, pkgPath, 'package.json');
const original = await readFile(fullPath, 'utf-8');
const pkg: PackageJson = JSON.parse(original);
pkg.private = true;
await writeFile(fullPath, JSON.stringify(pkg, null, 2));
return { path: fullPath, original };
};

const restoreAll = async (
backups: Array<{ path: string; original: string }>
) => {
for (const { path, original } of backups) {
await writeFile(path, original);
}
};

const main = async () => {
const backups = await Promise.all(VSCODE_EXTENSION_PATHS.map(markAsPrivate));

const opts: ExecSyncOptions = { stdio: 'inherit', cwd: ROOT };

try {
execSync('changeset publish', opts);
} finally {
await restoreAll(backups);
}
};

main();
31 changes: 31 additions & 0 deletions tooling/publish/publish-vscode.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
import { execSync, type ExecSyncOptions } from 'node:child_process';
import { copyFile, rm } from 'node:fs/promises';
import { resolve } from 'node:path';
import { ROOT, VSCODE_EXTENSION_PATHS } from './publish.constants';

const buildAndPublish = async (pkgRelativePath: string) => {
const cwd = resolve(ROOT, pkgRelativePath);
const opts: ExecSyncOptions = { stdio: 'inherit', cwd };
const licenseDest = resolve(cwd, 'LICENSE');

await copyFile(resolve(ROOT, 'LICENSE'), licenseDest);

try {
console.log(`\nBuilding ${pkgRelativePath}...`);
execSync('node --run build', opts);
execSync('vsce package --no-dependencies --out ./dist', opts);

console.log(`Publishing ${pkgRelativePath}...`);
execSync('vsce publish --packagePath ./dist/*.vsix', opts);
} finally {
await rm(licenseDest, { force: true });
}
};

const main = async () => {
for (const ext of VSCODE_EXTENSION_PATHS) {
await buildAndPublish(ext);
}
};

main();
5 changes: 5 additions & 0 deletions tooling/publish/publish.constants.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
import { resolve } from 'node:path';

export const ROOT = resolve(import.meta.dirname, '../..');

export const VSCODE_EXTENSION_PATHS = ['packages/vscode-extension'];
Loading