Skip to content

Commit 8350d5a

Browse files
committed
Migrate editor build and bump scripts to TypeScript and implement custom VSIX packaging script
- becasuse we don't publish to marketplaces, we don't need vsce. It should be replaced by our own build process. - remove these warnings [Pasted text] - such warn is shown in storybook[Pasted text] - storybook is not needed when building by the install script but it is always installed. any way we can avoid installing it? - updat also `install.ps1` [Changes] - to pnpm install also pass [Pasted text] - could scripts be written in typescript? - fix type errors [Pasted text] etc. ├── .eslintrc.json ├── apps │ └── editor │ ├── package.json │ ├── scripts │ │ ├── build.mts │ │ ├── bump.ts │ │ └── package.mts │ ├── tsconfig.json │ └── vite.config.ts ├── install.ps1 ├── install.sh ├── package.json ├── packages │ └── ui │ ├── .storybook │ │ ├── main.ts │ │ ├── preview.ts │ │ └── styles.css │ └── package.json ├── pnpm-workspace.yaml └── tsconfig.json
1 parent 3d9e4a5 commit 8350d5a

13 files changed

Lines changed: 2035 additions & 4919 deletions

File tree

‎apps/editor/package.json‎

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -4,12 +4,11 @@
44
"description": "Markdown prompts for chatbots, APIs, and CLIs with seamless integration",
55
"version": "2026.1114.458",
66
"scripts": {
7-
"build": "vsce package --no-dependencies",
8-
"vscode:prepublish": "npm run compile",
9-
"compile": "node scripts/build.mjs",
10-
"watch": "node scripts/build.mjs --watch",
7+
"build": "node scripts/build.mts && node scripts/package.mts",
8+
"compile": "node scripts/build.mts",
9+
"watch": "node scripts/build.mts --watch",
1110
"typecheck": "tsc --noEmit",
12-
"bump": "node scripts/bump.js",
11+
"bump": "node scripts/bump.ts",
1312
"test": "jest",
1413
"test:watch": "jest --watch"
1514
},
@@ -1383,15 +1382,14 @@
13831382
"@types/turndown": "5.0.5",
13841383
"@types/vscode": "1.96.0",
13851384
"@types/ws": "8.18.1",
1386-
"@vscode/vsce": "4.1.0",
13871385
"sass-embedded": "1.89.2",
13881386
"vite": "8.3.6"
13891387
},
13901388
"dependencies": {
13911389
"@cwc/ui": "workspace:*",
13921390
"@cwc/shared": "workspace:*",
13931391
"@mozilla/readability": "0.6.0",
1394-
"@vscode/codicons": "0.0.46-38",
1392+
"@vscode/codicons": "0.0.46-51",
13951393
"axios": "1.21.0",
13961394
"classnames": "2.5.1",
13971395
"dayjs": "1.11.10",
Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
1-
const start_time = Date.now()
2-
31
import * as fs from 'node:fs'
42
import * as path from 'node:path'
53
import { fileURLToPath } from 'node:url'
64
import { spawn } from 'node:child_process'
75

6+
const start_time = Date.now()
7+
88
const { build } = await import('vite')
99

1010
const app_dir = path.resolve(path.dirname(fileURLToPath(import.meta.url)), '..')
@@ -41,14 +41,14 @@ const run = async () => {
4141
stdio: 'inherit',
4242
shell: process.platform == 'win32'
4343
})
44-
tsc.on('error', (error) => {
44+
tsc.on('error', (error: Error) => {
4545
console.error(`Could not start tsc: ${error.message}`)
4646
})
4747
process.on('exit', () => tsc.kill())
4848
}
4949

5050
const pending = new Set(targets)
51-
const finish = (target) => {
51+
const finish = (target: string) => {
5252
if (pending.delete(target) && pending.size == 0) {
5353
const time = ((Date.now() - start_time) / 1000).toFixed(1)
5454
console.log(`Built in ${time}s.`)
@@ -68,7 +68,7 @@ const run = async () => {
6868
})
6969

7070
if (is_watch) {
71-
result.on('event', (event) => {
71+
;(result as any).on('event', (event: any) => {
7272
if (event.code == 'END' || event.code == 'ERROR') {
7373
finish(target)
7474
}
@@ -79,7 +79,7 @@ const run = async () => {
7979
}
8080
}
8181

82-
run().catch((error) => {
82+
run().catch((error: any) => {
8383
console.error(error)
8484
process.exit(1)
85-
})
85+
})

‎apps/editor/scripts/bump.js‎

Lines changed: 0 additions & 45 deletions
This file was deleted.

‎apps/editor/scripts/bump.ts‎

Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
const fs = require('fs')
2+
const path = require('path')
3+
const { execSync } = require('child_process')
4+
const readline = require('readline')
5+
6+
const pkg_path = path.resolve(__dirname, '../package.json')
7+
const pkg = JSON.parse(fs.readFileSync(pkg_path, 'utf-8'))
8+
9+
const date = new Date()
10+
const year = date.getFullYear()
11+
const month = String(date.getMonth() + 1).padStart(2, '0')
12+
const day = String(date.getDate()).padStart(2, '0')
13+
const date_prefix = `${year}.${month}${day}`
14+
15+
const version_parts = pkg.version.split('.')
16+
const last_segment = parseInt(version_parts.pop(), 10) || 0
17+
18+
const next_segment = last_segment + 1
19+
const next_version = `${date_prefix}.${next_segment}`
20+
21+
const rl = readline.createInterface({
22+
input: process.stdin,
23+
output: process.stdout
24+
})
25+
26+
rl.question(
27+
`Bump version of the VS Code extension to ${next_version}? (y/N) `,
28+
(answer: string) => {
29+
if (answer.toLowerCase() === 'y') {
30+
pkg.version = next_version
31+
fs.writeFileSync(pkg_path, JSON.stringify(pkg, null, 2) + '\n')
32+
console.log(`Bumped version of the VS Code extension to ${pkg.version}`)
33+
34+
try {
35+
execSync(`git add "${pkg_path}"`, { stdio: 'ignore' })
36+
execSync(
37+
`git commit --no-verify -m "Bump version of the VS Code extension to ${pkg.version}"`,
38+
{
39+
stdio: 'ignore'
40+
}
41+
)
42+
console.log('Successfully committed the version bump.')
43+
} catch (error: any) {
44+
console.error('Failed to commit version bump:', error.message)
45+
}
46+
} else {
47+
console.log('Version bump aborted.')
48+
}
49+
rl.close()
50+
}
51+
)

0 commit comments

Comments
 (0)