From c033761afcf5958228b16fe62cfd6cbc05e3b1a5 Mon Sep 17 00:00:00 2001 From: George Cook Date: Wed, 24 Feb 2021 11:02:05 +0100 Subject: [PATCH] adds scripts for easy remote/local npm switching --- bsc-plugin/package.json | 202 ++++++++++++++-------------- bsc-plugin/scripts/install-local.js | 33 +++++ bsc-plugin/scripts/install-npm.js | 21 +++ bsc-plugin/src/plugin.spec.ts | 2 +- bsc-plugin/tsconfig.json | 47 +++---- 5 files changed, 175 insertions(+), 130 deletions(-) create mode 100644 bsc-plugin/scripts/install-local.js create mode 100644 bsc-plugin/scripts/install-npm.js diff --git a/bsc-plugin/package.json b/bsc-plugin/package.json index 82903cc5..88e03408 100644 --- a/bsc-plugin/package.json +++ b/bsc-plugin/package.json @@ -1,104 +1,106 @@ { - "name": "rooibos-roku", - "version": "4.0.9", - "description": "simple, flexible, fun brightscript test framework for roku scenegraph apps - roku brighterscript plugin", - "files": [ - "dist/**/!(*.spec.*)*" - ], - "main": "dist/plugin.js", - "directories": { - "test": "test" - }, - "dependencies": { - "@types/node": "^14.14.16", - "source-map": "^0.7.3", - "stringify-object": "^3.3.0", - "vscode-languageserver": "~6.1.1", - "vscode-languageserver-protocol": "~3.15.3" - }, - "devDependencies": { - "@types/chai": "^4.1.2", - "@types/expect": "^24.3.0", - "@types/mocha": "^5.2.7", - "@types/sinon": "^9.0.4", - "@typescript-eslint/eslint-plugin": "^4.4.1", - "@typescript-eslint/parser": "^4.4.1", - "brighterscript": "^0.30.4", - "chai": "^4.2.0", - "chai-files": "^1.4.0", - "chai-subset": "^1.6.0", - "eslint": "^7.11.0", - "eslint-plugin-github": "^4.1.1", - "eslint-plugin-no-only-tests": "^2.4.0", - "fs-extra": "^9.0.1", - "minimatch": "^3.0.4", - "mocha": "^7.1.1", - "nyc": "^15.1.0", - "roku-deploy": "^3.2.4", - "sinon": "^9.0.2", - "source-map-support": "^0.5.13", - "ts-node": "^9.0.0", - "typescript": "^3.8.3", - "typescript-formatter": "^7.2.2" - }, - "scripts": { - "clean": "rm -rf ./dist && mkdir dist", - "compile": "npm run clean && tsc -p .", - "prepublishOnly": "npm run build", - "lint": "eslint \"src/**\"", - "build": "npm run compile && cp -r ../framework/src/source ./dist/lib/framework", - "test": "TS_NODE_TRANSPILE_ONLY=true mocha --full-trace --bail", - "coverage": "nyc report --reporter=text-lcov > coverage.lcov && codecov", - "publish-npm": "npm run test && npm publish", - "publish-npm:beta": "npm run test && npm publish --tag=beta" - }, - "preferGlobal": true, - "keywords": [ - "brightscript", - "scenegraph", - "roku", - "rooibos", - "britherscript" - ], - "author": "George Cook", - "license": "ISC", - "watch": { - "test": { - "extensions": "ts", - "patterns": [ - "src" - ] - } - }, - "nyc": { - "include": [ - "src/**/!(*.spec).ts" - ], - "extension": [ - ".ts" + "name": "rooibos-roku", + "version": "4.1.0", + "description": "simple, flexible, fun brightscript test framework for roku scenegraph apps - roku brighterscript plugin", + "files": [ + "dist/**/!(*.spec.*)*" ], - "require": [ - "ts-node/register", - "source-map-support/register" + "main": "dist/plugin.js", + "directories": { + "test": "test" + }, + "dependencies": { + "@types/node": "^14.14.16", + "source-map": "^0.7.3", + "stringify-object": "^3.3.0", + "vscode-languageserver": "~6.1.1", + "vscode-languageserver-protocol": "~3.15.3" + }, + "devDependencies": { + "@types/chai": "^4.1.2", + "@types/expect": "^24.3.0", + "@types/mocha": "^5.2.7", + "@types/sinon": "^9.0.4", + "@typescript-eslint/eslint-plugin": "^4.4.1", + "@typescript-eslint/parser": "^4.4.1", + "brighterscript": "^0.32.2", + "chai": "^4.2.0", + "chai-files": "^1.4.0", + "chai-subset": "^1.6.0", + "eslint": "^7.11.0", + "eslint-plugin-github": "^4.1.1", + "eslint-plugin-no-only-tests": "^2.4.0", + "fs-extra": "^9.1.0", + "minimatch": "^3.0.4", + "mocha": "^7.1.1", + "nyc": "^15.1.0", + "roku-deploy": "^3.2.4", + "sinon": "^9.0.2", + "source-map-support": "^0.5.13", + "ts-node": "^9.0.0", + "typescript": "^3.8.3", + "typescript-formatter": "^7.2.2" + }, + "scripts": { + "clean": "rm -rf ./dist && mkdir dist", + "compile": "npm run clean && tsc -p .", + "prepublishOnly": "npm run build", + "lint": "eslint \"src/**\"", + "build": "npm run compile && cp -r ../framework/src/source ./dist/lib/framework", + "test": "TS_NODE_TRANSPILE_ONLY=true mocha --full-trace --bail", + "coverage": "nyc report --reporter=text-lcov > coverage.lcov && codecov", + "publish-npm": "npm run test && npm publish", + "publish-npm:beta": "npm run test && npm publish --tag=beta", + "local": "ts-node scripts/install-local.js", + "remote": "ts-node scripts/install-npm.js" + }, + "preferGlobal": true, + "keywords": [ + "brightscript", + "scenegraph", + "roku", + "rooibos", + "britherscript" ], - "reporter": [ - "text-summary", - "html" - ], - "sourceMap": true, - "instrument": true, - "check-coverage": true, - "lines": 5, - "statements": 5, - "functions": 5, - "branches": 5 - }, - "mocha": { - "spec": "src/**/*.spec.ts", - "fullTrace": true, - "require": [ - "source-map-support/register", - "ts-node/register" - ] - } + "author": "George Cook", + "license": "ISC", + "watch": { + "test": { + "extensions": "ts", + "patterns": [ + "src" + ] + } + }, + "nyc": { + "include": [ + "src/**/!(*.spec).ts" + ], + "extension": [ + ".ts" + ], + "require": [ + "ts-node/register", + "source-map-support/register" + ], + "reporter": [ + "text-summary", + "html" + ], + "sourceMap": true, + "instrument": true, + "check-coverage": true, + "lines": 5, + "statements": 5, + "functions": 5, + "branches": 5 + }, + "mocha": { + "spec": "src/**/*.spec.ts", + "fullTrace": true, + "require": [ + "source-map-support/register", + "ts-node/register" + ] + } } diff --git a/bsc-plugin/scripts/install-local.js b/bsc-plugin/scripts/install-local.js new file mode 100644 index 00000000..96eb9600 --- /dev/null +++ b/bsc-plugin/scripts/install-local.js @@ -0,0 +1,33 @@ +/** + * Installs a local version of all the rokucommunity dependent packages into this project + */ + +import * as fsExtra from 'fs-extra'; +import * as path from 'path'; +import * as childProcess from 'child_process'; +import * as rimraf from 'rimraf'; + +//set the cwd to the root of this project +let thisProjectRootPath = path.join(__dirname, '..'); +process.chdir(thisProjectRootPath); +let packageJson = JSON.parse(fsExtra.readFileSync('package.json').toString()); + +let devPackages = { + 'brighterscript': '/home/george/hope/open-source/vsc/brighterscript' +}; + +for (let packageName in devPackages) { + console.log(`adding dev package: '${packageName}' to package.json`); + packageJson.devDependencies[packageName] = `${devPackages[packageName]}`; + rimraf.sync(path.join('node_modules', packageName)); +} + +console.log('saving package.json changes'); +fsExtra.writeFileSync('package.json', JSON.stringify(packageJson, null, 4)); +if (fsExtra.existsSync('package-lock.json')) { + fsExtra.rmSync('package-lock.json'); +} +console.log('install packages'); +childProcess.execSync('npm i', { + stdio: 'inherit' +}); diff --git a/bsc-plugin/scripts/install-npm.js b/bsc-plugin/scripts/install-npm.js new file mode 100644 index 00000000..5b867448 --- /dev/null +++ b/bsc-plugin/scripts/install-npm.js @@ -0,0 +1,21 @@ +/** + * Installs a local version of all the rokucommunity dependent packages into this project + */ + +import * as fsExtra from 'fs-extra'; +import * as path from 'path'; +import * as childProcess from 'child_process'; +import * as rimraf from 'rimraf'; + +//set the cwd to the root of this project +let thisProjectRootPath = path.join(__dirname, '..'); +process.chdir(thisProjectRootPath); + +rimraf.sync(path.join('node_modules/brighterscript')); +if (fsExtra.existsSync('package-lock.json')) { + fsExtra.rmSync('package-lock.json'); +} +console.log('install packages'); +childProcess.execSync('npm i brighterscript@latest --save-dev', { + stdio: 'inherit' +}); diff --git a/bsc-plugin/src/plugin.spec.ts b/bsc-plugin/src/plugin.spec.ts index acd53f8f..9138719a 100644 --- a/bsc-plugin/src/plugin.spec.ts +++ b/bsc-plugin/src/plugin.spec.ts @@ -541,7 +541,7 @@ end function`).trim()); }); -describe.only('run a local project', () => { +describe.skip('run a local project', () => { it('sanity checks on parsing - only run this outside of ci', () => { let programBuilder = new ProgramBuilder(); let swv = { diff --git a/bsc-plugin/tsconfig.json b/bsc-plugin/tsconfig.json index 65d1e6e4..13a63622 100644 --- a/bsc-plugin/tsconfig.json +++ b/bsc-plugin/tsconfig.json @@ -1,31 +1,20 @@ { - "compilerOptions": { - "noImplicitAny": false, - "target": "ES2017", - "module": "commonjs", - "sourceMap": true, - "rootDir": "src", - "outDir": "dist", - "declaration": true, - "strict": true, - "strictNullChecks": false, - "forceConsistentCasingInFileNames": true, - "preserveConstEnums": true, - "downlevelIteration": true, - "noUnusedLocals": true, - "allowSyntheticDefaultImports": true, - "lib": [ - "es2017", - "es2019.array" - ] - }, - "include": [ - "src/**/*.ts" - ], - "exclude": [ - "node_modules/**/*" - ], - "ts-node": { - "transpileOnly": true - } + "compilerOptions": { + "noImplicitAny": false, + "module": "commonjs", + "sourceMap": true, + "rootDir": "src", + "outDir": "./dist", + "strictNullChecks": false, + "forceConsistentCasingInFileNames": true, + "preserveConstEnums": true, + "allowJs": true, + "target": "ES2017", + "downlevelIteration": true + }, + "allowSyntheticDefaultImports": true, + "lib": ["es2017", "es2019.array", "esnext", "dom"], + "outDir": "./dist", + "exclude": ["node_modules/**/*"], + "include": ["./src/**/*"] }