Skip to content

Commit

Permalink
feat: standalone version
Browse files Browse the repository at this point in the history
  • Loading branch information
fjc0k committed Apr 16, 2020
1 parent 622636d commit 153c99c
Show file tree
Hide file tree
Showing 5 changed files with 142 additions and 2 deletions.
14 changes: 12 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,14 @@
"publisher": "JayFong",
"main": "./out/extension.js",
"bin": "./out/cli.js",
"files": [
"out"
],
"scripts": {
"compile": "rimraf out && tsc -p tsconfig.build.json",
"postinstall": "node ./node_modules/vscode/bin/install",
"release": "standard-version -a && git push --follow-tags origin master && vsce publish",
"release": "standard-version -a && git push --follow-tags origin master && vsce publish && npm run standalone:publish",
"standalone:publish": "ts-node -T ./scripts/publish-standalone.ts",
"test": "jest",
"vscode:prepublish": "npm run compile",
"watch": "rimraf out && tsc -watch -p tsconfig.build.json"
Expand Down Expand Up @@ -80,10 +84,14 @@
"yargs": "^15.3.1"
},
"devDependencies": {
"@types/cross-spawn": "^6.0.1",
"@types/fs-extra": "^8.1.0",
"@types/jest": "^25.2.1",
"@types/node": "^10.17.19",
"@types/rimraf": "^3.0.0",
"cross-spawn": "^7.0.2",
"eslint": "^6",
"fs-extra": "^9.0.0",
"haoma": "^1.7.0",
"husky": "^4",
"jest": "^25.3.0",
Expand All @@ -93,11 +101,13 @@
"standard-version": "^6.0.1",
"tempy": "^0.5.0",
"ts-jest": "^25.3.1",
"ts-node": "^8.8.2",
"typescript": "^3",
"vscode": "^1.1.28"
},
"engines": {
"vscode": "^1.14.0"
},
"icon": "assets/logo.png"
"icon": "assets/logo.png",
"packageName": "vscode-generate-index-standalone"
}
85 changes: 85 additions & 0 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

40 changes: 40 additions & 0 deletions scripts/publish-standalone.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
import pkg from '../package.json'
import tmp from 'tempy'
import { copySync, writeFileSync } from 'fs-extra'
import { sync as exec } from 'cross-spawn'
import { join } from 'path'
import { sync as rmrf } from 'rimraf'

const packageInfo: Record<keyof typeof pkg, any> = {
...pkg,
'name': pkg.packageName,
'main': './out/generateIndex.js',
'scripts': undefined,
'contributes': undefined,
'devDependencies': undefined,
'engines': undefined,
'jest': undefined,
'lint-staged': undefined,
'activationEvents': undefined,
'categories': undefined,
'displayName': undefined,
'packageName': undefined,
'publisher': undefined,
'husky': undefined,
'icon': undefined,
}

const packageDir = tmp.directory()

writeFileSync(
join(packageDir, 'package.json'),
JSON.stringify(packageInfo, null, 2),
)

copySync(join(__dirname, '../LICENSE'), join(packageDir, 'LICENSE'))
copySync(join(__dirname, '../README.md'), join(packageDir, 'README.md'))
copySync(join(__dirname, '../out'), join(packageDir, 'out'))

exec('npm', ['publish'], { cwd: packageDir, stdio: 'inherit' })

rmrf(packageDir)
4 changes: 4 additions & 0 deletions tsconfig.build.json
Original file line number Diff line number Diff line change
@@ -1,4 +1,8 @@
{
"extends": "./tsconfig.json",
"compilerOptions": {
"resolveJsonModule": false
},
"include": ["src"],
"exclude": ["**/__*__", "**/*.test.ts"]
}
1 change: 1 addition & 0 deletions tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
"declaration": true,
"esModuleInterop": true,
"skipLibCheck": true,
"resolveJsonModule": true,
"preserveSymlinks": true,
"strict": true,
"newLine": "lf"
Expand Down

0 comments on commit 153c99c

Please sign in to comment.