Skip to content

Commit

Permalink
closes #21
Browse files Browse the repository at this point in the history
  • Loading branch information
zardoy committed Nov 10, 2021
1 parent ee798b7 commit 51c83ed
Show file tree
Hide file tree
Showing 11 changed files with 43 additions and 141 deletions.
89 changes: 0 additions & 89 deletions esbuild.mjs

This file was deleted.

4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,10 @@
"name": "vscode-framework",
"private": true,
"scripts": {
"start": "node prepare.mjs && tsc-watch -b tsconfig.dev.json --onSuccess \"node esbuild.mjs development\"",
"start": "node prepare.mjs && tsc-watch -b tsconfig.dev.json --onSuccess \"node patch-ts-output.mjs\"",
"eslint": "eslint packages/*/src/**/*.ts",
"test": "jest",
"build": "node prepare.mjs && tsc -b tsconfig.prod.json && tsc -p tsconfig.only-typechecking.json && node esbuild.mjs production"
"build": "node prepare.mjs && tsc -b tsconfig.prod.json && tsc -p tsconfig.only-typechecking.json"
},
"devDependencies": {
"@babel/cli": "^7.16.0",
Expand Down
1 change: 0 additions & 1 deletion packages/vscode-extra/tsconfig.prod.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
"extends": "@zardoy/tsconfig/node-lib",
"compilerOptions": {
"composite": true,
"emitDeclarationOnly": true,
"rootDir": "src",
"outDir": "build"
},
Expand Down
17 changes: 4 additions & 13 deletions packages/vscode-framework/src/cli/buildExtension.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@ import { LauncherCLIParams, launchVscode } from './launcher'
import { generateAndWriteManifest } from './manifest-generator'
import { newTypesGenerator } from './typesGenerator'
import { WebSocketServer } from 'ws'
declare const __DEV__: boolean

const debug = Debug('vscode-framework:bulid-extension')

Expand Down Expand Up @@ -56,9 +55,7 @@ export const startExtensionDevelopment = async (
mode,
outDir,
})
await del(
Object.values(EXTENSION_ENTRYPOINTS).flatMap(jsOut => [join(outDir, jsOut), join(outDir, `${jsOut}.map`)]),
)
await del(Object.values(EXTENSION_ENTRYPOINTS).flatMap(jsOut => [join(outDir, jsOut), join(outDir, `${jsOut}.map`)]))
if (mode === 'production') {
await buildExtension(params)
return
Expand Down Expand Up @@ -170,8 +167,7 @@ export const startExtensionDevelopment = async (
watcher.on('add', onFileChange)
watcher.on('unlink', async path => {
// TODO also run typesGenerator
if (path.endsWith(manifestPath))
console.log(kleur.red('[vscode-framework] Manifest is missing! Return it back.'))
if (path.endsWith(manifestPath)) console.log(kleur.red('[vscode-framework] Manifest is missing! Return it back.'))
// TODO! run typesGenerator configurationType.ts was removed, for now need to rerun start script
})
return {
Expand Down Expand Up @@ -254,11 +250,7 @@ export const buildExtension = async ({
outDir,
resolvedManifest: generatedManifest,
defineEnv: {
IDS_PREFIX: config.prependIds
? config.prependIds.style === 'camelCase'
? camelCase(generatedManifest.name)
: generatedManifest.name
: undefined,
IDS_PREFIX: config.prependIds ? (config.prependIds.style === 'camelCase' ? camelCase(generatedManifest.name) : generatedManifest.name) : undefined,
...define,
},
config,
Expand Down Expand Up @@ -287,8 +279,7 @@ export const checkEntrypoint = (config: Config) => {
})
const source = project.addSourceFileAtPath(entryPoint)
// TODO fancy errors
if (!source.getVariableDeclarationOrThrow('activate').isExported())
throw new Error("activate function isn't exported")
if (!source.getVariableDeclarationOrThrow('activate').isExported()) throw new Error("activate function isn't exported")

console.timeEnd('check')
}
28 changes: 13 additions & 15 deletions packages/vscode-framework/src/cli/commands.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@ import { SuperCommander } from './commander'
import { addStandaloneCommands } from './standaloneCommands'
import { generateTypes } from './typesGenerator'
import { generateAndWriteManifest } from '.'
declare const __DEV__: boolean

const debug = Debug('vscode-framework:cli')

Expand Down Expand Up @@ -55,16 +54,17 @@ commander.command(
},
)

commander.command(
'generate-types',
'Generate TypeScript typings (from contribution points) and place them to nearest node_modules for working with framework',
{
hidden: true,
},
async () => {
await generateTypes({ nodeModulesDir: __DEV__ ? (await pkdDir(__dirname))! : process.cwd() })
},
)
// OLD types generator, isn't ready for this TS world
// commander.command(
// 'generate-types',
// 'Generate TypeScript typings (from contribution points) and place them to nearest node_modules for working with framework',
// {
// hidden: true,
// },
// async () => {
// await generateTypes({ nodeModulesDir: __DEV__ ? (await pkdDir(__dirname))! : process.cwd() })
// },
// )

const useOutForDebugging = true
const relativePath = useOutForDebugging ? 'out' : 'node_modules/.vscode-extension'
Expand Down Expand Up @@ -92,8 +92,7 @@ commander.command(
// TODO use config's default
defaultValue: false,
// reformat description
description:
'If --web is present, you can launch web extension in desktop VSCode, instead of in browser',
description: 'If --web is present, you can launch web extension in desktop VSCode, instead of in browser',
},
'--skip-launching': {
defaultValue: false,
Expand Down Expand Up @@ -153,8 +152,7 @@ commander.command(

// TODO build path
// TODO move check to schema
if (!config.target.desktop && !config.target.web)
throw new Error('Both targets are disabled in config. Enable either desktop or wb')
if (!config.target.desktop && !config.target.web) throw new Error('Both targets are disabled in config. Enable either desktop or wb')

if (!skipTypechecking && fsExtra.existsSync('./tsconfig.json')) {
const date = Date.now()
Expand Down
1 change: 0 additions & 1 deletion packages/vscode-framework/tsconfig.prod.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
"extends": "@zardoy/tsconfig/node-lib",
"compilerOptions": {
"composite": true,
"emitDeclarationOnly": true,
"rootDir": "src",
"outDir": "build"
},
Expand Down
1 change: 0 additions & 1 deletion packages/vscode-manifest/tsconfig.prod.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
"extends": "@zardoy/tsconfig/node-lib",
"compilerOptions": {
"composite": true,
"emitDeclarationOnly": true,
"rootDir": "src",
"outDir": "build"
},
Expand Down
19 changes: 19 additions & 0 deletions patch-ts-output.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
//@ts-check
import fs from 'fs'

const pathsToPatch = {
'packages/vscode-framework/build/index.d.ts'(contents) {
return contents.replace("RegularCommandsTypeToReplace: '';", '').replace("SettingsTypeToReplace: '';", '')
},
'packages/vscode-framework/build/framework/commands.d.ts'(contents) {
return contents.replace(/RegularCommandsTypeToReplace/g, '[k in keyof RegularCommands]')
},
'packages/vscode-framework/build/framework/settings.d.ts'(contents) {
return contents.replace(/"SettingsTypeToReplace"/g, 'keyof Settings')
},
}
// TODO! combine with incremental
for (const [path, patch] of Object.entries(pathsToPatch)) {
const contents = await fs.promises.readFile(path, 'utf-8')
await fs.promises.writeFile(path, patch(contents), 'utf-8')
}
8 changes: 3 additions & 5 deletions prepare.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -5,15 +5,13 @@ import * as globby from 'globby'

let buildDel = await globby.globby(['packages/**/*.tsbuildinfo', 'packages/*/build/**'])

buildDel = buildDel.filter(
v =>
v !== 'packages/vscode-framework/build/client.d.ts' &&
v !== 'packages/vscode-framework/build/extensionBootstrap.ts',
)
buildDel = buildDel.filter(v => v !== 'packages/vscode-framework/build/client.d.ts' && v !== 'packages/vscode-framework/build/extensionBootstrap.ts')

await del(buildDel, {
// TODO! read gitignores automatically
// gitignore: true,
})

// projects with compiste: true must run twice
// we're losing a lot of time here
await execa('tsc', '-b tsconfig.prod.json'.split(' '), { preferLocal: true }).catch(e => {})
14 changes: 1 addition & 13 deletions scripts/formMonorepo.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,18 +17,6 @@ import { getMonorepoPackages } from './common'

for (const monorepoPackage of packagesDirs) {
const fromPackage = (...p: string[]) => join('packages', monorepoPackage, ...p)
// eslint-disable-next-line no-await-in-loop
await modifyPackageJsonFile({ dir: fromPackage() }, packageJson => {
// temporarily
packageJson.repository = {
url: 'https://github.com/zardoy/vscode-framework.git',
directory: fromPackage().replace('\\', '/'),
}
return packageJson
})
// if (fs.existsSync(fromPackage(packageTsconfigName))) {
// console.warn(monorepoPackage, 'has tsconfig.json')
// }
for (const { path, tsconfig } of [
{
path: packageTsconfigs.dev,
Expand All @@ -45,7 +33,7 @@ import { getMonorepoPackages } from './common'
extends: '@zardoy/tsconfig/node-lib',
compilerOptions: {
composite: true,
emitDeclarationOnly: true,
// emitDeclarationOnly: true,
rootDir: 'src',
outDir: 'build',
},
Expand Down
2 changes: 1 addition & 1 deletion tsconfig.prod.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,4 +12,4 @@
}
],
"files": []
}
}

0 comments on commit 51c83ed

Please sign in to comment.