diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 2e7e8c0b5..658fdd2af 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -44,7 +44,6 @@ jobs: - run: npm run build #create npm package - run: npm pack - - run: npm run test-related-projects #create GitHub release - name: Create GitHub Release diff --git a/CHANGELOG.md b/CHANGELOG.md index bd6cbd93a..dbc0bd441 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -78,6 +78,43 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ## [0.66.0-alpha.0](https://github.com/rokucommunity/brighterscript/compare/v0.65.1...v0.66.0-alpha.0) - 2023-06-09 ### Changed - all the type tracking stuff! +## [0.65.8](https://github.com/rokucommunity/brighterscript/compare/v0.65.7...v0.65.8) - 2023-10-06 +### Added + - interface parameter support ([#924](https://github.com/rokucommunity/brighterscript/pull/924)) +### Changed + - Bump postcss from 8.2.15 to 8.4.31 ([#928](https://github.com/rokucommunity/brighterscript/pull/928)) +### Fixed + - chore: fix typescript typing for `Deferred` ([#923](https://github.com/rokucommunity/brighterscript/pull/923)) + + + +## [0.65.7](https://github.com/rokucommunity/brighterscript/compare/v0.65.6...v0.65.7) - 2023-09-28 +### Fixed + - fix bug in --noproject flag logic ([#922](https://github.com/rokucommunity/brighterscript/pull/922)) + + + +## [0.65.6](https://github.com/rokucommunity/brighterscript/compare/v0.65.5...v0.65.6) - 2023-09-28 +### Added + - `noProject` flag to bsc so `bsconfig.json` loading can be skipped entirely even if present ([#868](https://github.com/rokucommunity/brighterscript/pull/868)) +### Changed + - docs: add some more details to the plugins ([#913](https://github.com/rokucommunity/brighterscript/pull/913)) + - docs: add missing emitDefinitions ([#893](https://github.com/rokucommunity/brighterscript/pull/893)) +### Fixed + - incorrect quasi location in template string ([#921](https://github.com/rokucommunity/brighterscript/pull/921)) + - `UnaryExpression` transpile for namespace and const ([#914](https://github.com/rokucommunity/brighterscript/pull/914)) + + + +## [0.65.5](https://github.com/rokucommunity/brighterscript/compare/v0.65.4...v0.65.5) - 2023-09-06 +### Added + - support overriding bs_const values in bsconfig ([#887](https://github.com/rokucommunity/brighterscript/pull/887)) + - allow optionally specifying bslib destination directory ([#871](https://github.com/rokucommunity/brighterscript/pull/871)) + - Print diagnostic related information ([#867](https://github.com/rokucommunity/brighterscript/pull/867)) +### Fixed + - ensure consistent insertion of bslib.brs ([#870](https://github.com/rokucommunity/brighterscript/pull/870)) + - Fix crashes in util for null ranges ([#869](https://github.com/rokucommunity/brighterscript/pull/869)) + - Fix tab issue when printing diagnostics ([#865](https://github.com/rokucommunity/brighterscript/pull/865)) @@ -1719,13 +1756,3 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ## [0.1.0](https://github.com/rokucommunity/brighterscript/compare/v0.1.0...v0.1.0) - 2019-08-10 ### Changed - Cloned from [brightscript-language](https://github.com/rokucommunity/brightscript-language) - - - - - - - - - - diff --git a/README.md b/README.md index 971ed7e35..27895285c 100644 --- a/README.md +++ b/README.md @@ -469,6 +469,12 @@ Type: `boolean` Emit full paths to files when printing diagnostics to the console. Defaults to `false`. +#### `emitDefinitions` + +Type: `boolean` + +Emit type definition files (`d.bs`) during transpile. Defaults to `false`. + #### `diagnosticFilters` Type: `Array + + ## Methods Interfaces can describe complex methods as well ```brighterscript @@ -105,6 +107,5 @@ end interface View the transpiled BrightScript code ```BrightScript - ``` - \ No newline at end of file + diff --git a/docs/plugins.md b/docs/plugins.md index 327379700..d5964ace2 100644 --- a/docs/plugins.md +++ b/docs/plugins.md @@ -418,6 +418,29 @@ export default function plugin() { } ``` +## Modifying `bsconfig.json` via a plugin + +In some cases you may want to modify the project's configuration via a plugin, such as to change settings based on environment variables or to dynamically modify the project's `files` array. Plugins may do so in the `beforeProgramCreate` step. For example, here's a plugin which adds an additional file to the build: +```typescript +import { CompilerPlugin, ProgramBuilder } from 'brighterscript'; + +export default function plugin() { + return { + name: 'addFilesDynamically', + beforeProgramCreate: (builder: ProgramBuilder) => { + if (!builder.options.files) { + builder.options.files = []; + } + + builder.options.files.push({ + src: "path/to/plugin/file.bs", + dest: "some/destination/path/goes/here" + }) + } + } as CompilerPlugin; +} +``` + ## File API By default, BrighterScript only parses files that it knows how to handle. Generally this includes `.xml` files in the compontents folder, `.brs`, `.bs` and `.d.bs` files. Other files may be handled in the future, such as `manifest`, `.ts` and possibly more. All other files are loaded into the program as `AssetFile` types and have no special handling or processing. @@ -557,4 +580,4 @@ Here's an example file showing all three paths: //location on device pkgPath: "source/main.brs" } -``` \ No newline at end of file +``` diff --git a/package-lock.json b/package-lock.json index 039300eef..550077db5 100644 --- a/package-lock.json +++ b/package-lock.json @@ -6118,6 +6118,12 @@ "node": ">= 8" } }, + "node_modules/picocolors": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/picocolors/-/picocolors-1.0.0.tgz", + "integrity": "sha512-1fygroTLlHu66zi26VoTDv8yRgm0Fccecssto+MhsZ0D/DGW2sm8E8AjW7NU5VVTRt5GxbeZ5qBuJr+HyLYkjQ==", + "dev": true + }, "node_modules/picomatch": { "version": "2.3.1", "resolved": "https://registry.npmjs.org/picomatch/-/picomatch-2.3.1.tgz", @@ -6157,21 +6163,31 @@ } }, "node_modules/postcss": { - "version": "8.2.15", - "resolved": "https://registry.npmjs.org/postcss/-/postcss-8.2.15.tgz", - "integrity": "sha512-2zO3b26eJD/8rb106Qu2o7Qgg52ND5HPjcyQiK2B98O388h43A448LCslC0dI2P97wCAQRJsFvwTRcXxTKds+Q==", + "version": "8.4.31", + "resolved": "https://registry.npmjs.org/postcss/-/postcss-8.4.31.tgz", + "integrity": "sha512-PS08Iboia9mts/2ygV3eLpY5ghnUcfLV/EXTOW1E2qYxJKGGBUtNjN76FYHnMs36RmARn41bC0AZmn+rR0OVpQ==", "dev": true, + "funding": [ + { + "type": "opencollective", + "url": "https://opencollective.com/postcss/" + }, + { + "type": "tidelift", + "url": "https://tidelift.com/funding/github/npm/postcss" + }, + { + "type": "github", + "url": "https://github.com/sponsors/ai" + } + ], "dependencies": { - "colorette": "^1.2.2", - "nanoid": "^3.1.23", - "source-map": "^0.6.1" + "nanoid": "^3.3.6", + "picocolors": "^1.0.0", + "source-map-js": "^1.0.2" }, "engines": { "node": "^10 || ^12 || >=14" - }, - "funding": { - "type": "opencollective", - "url": "https://opencollective.com/postcss/" } }, "node_modules/postcss-values-parser": { @@ -6188,13 +6204,22 @@ "node": ">=6.14.4" } }, - "node_modules/postcss/node_modules/source-map": { - "version": "0.6.1", - "resolved": "https://registry.npmjs.org/source-map/-/source-map-0.6.1.tgz", - "integrity": "sha512-UjgapumWlbMhkBgzT7Ykc5YXUT46F0iKu8SGXq0bcwP5dz/h0Plj6enJqjz1Zbq2l5WaqYnrVbwWOWMyF3F47g==", + "node_modules/postcss/node_modules/nanoid": { + "version": "3.3.6", + "resolved": "https://registry.npmjs.org/nanoid/-/nanoid-3.3.6.tgz", + "integrity": "sha512-BGcqMMJuToF7i1rt+2PWSNVnWIkGCU78jBG3RxO/bZlnZPK2Cmi2QaffxGO/2RvWi9sL+FAiRiXMgsyxQ1DIDA==", "dev": true, + "funding": [ + { + "type": "github", + "url": "https://github.com/sponsors/ai" + } + ], + "bin": { + "nanoid": "bin/nanoid.cjs" + }, "engines": { - "node": ">=0.10.0" + "node": "^10 || ^12 || ^13.7 || ^14 || >=15.0.1" } }, "node_modules/postman-request": { @@ -6951,6 +6976,15 @@ "node": ">= 8" } }, + "node_modules/source-map-js": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/source-map-js/-/source-map-js-1.0.2.tgz", + "integrity": "sha512-R0XvVJ9WusLiqTCEiGCmICCMplcCkIwwR11mOSD9CR5u+IXYdiseeEuXCVAjS54zqwkLcPNnmU4OeJ6tUrWhDw==", + "dev": true, + "engines": { + "node": ">=0.10.0" + } + }, "node_modules/source-map-support": { "version": "0.5.19", "resolved": "https://registry.npmjs.org/source-map-support/-/source-map-support-0.5.19.tgz", @@ -12516,6 +12550,12 @@ "centra": "^2.4.2" } }, + "picocolors": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/picocolors/-/picocolors-1.0.0.tgz", + "integrity": "sha512-1fygroTLlHu66zi26VoTDv8yRgm0Fccecssto+MhsZ0D/DGW2sm8E8AjW7NU5VVTRt5GxbeZ5qBuJr+HyLYkjQ==", + "dev": true + }, "picomatch": { "version": "2.3.1", "resolved": "https://registry.npmjs.org/picomatch/-/picomatch-2.3.1.tgz", @@ -12543,20 +12583,20 @@ "dev": true }, "postcss": { - "version": "8.2.15", - "resolved": "https://registry.npmjs.org/postcss/-/postcss-8.2.15.tgz", - "integrity": "sha512-2zO3b26eJD/8rb106Qu2o7Qgg52ND5HPjcyQiK2B98O388h43A448LCslC0dI2P97wCAQRJsFvwTRcXxTKds+Q==", + "version": "8.4.31", + "resolved": "https://registry.npmjs.org/postcss/-/postcss-8.4.31.tgz", + "integrity": "sha512-PS08Iboia9mts/2ygV3eLpY5ghnUcfLV/EXTOW1E2qYxJKGGBUtNjN76FYHnMs36RmARn41bC0AZmn+rR0OVpQ==", "dev": true, "requires": { - "colorette": "^1.2.2", - "nanoid": "^3.1.23", - "source-map": "^0.6.1" + "nanoid": "^3.3.6", + "picocolors": "^1.0.0", + "source-map-js": "^1.0.2" }, "dependencies": { - "source-map": { - "version": "0.6.1", - "resolved": "https://registry.npmjs.org/source-map/-/source-map-0.6.1.tgz", - "integrity": "sha512-UjgapumWlbMhkBgzT7Ykc5YXUT46F0iKu8SGXq0bcwP5dz/h0Plj6enJqjz1Zbq2l5WaqYnrVbwWOWMyF3F47g==", + "nanoid": { + "version": "3.3.6", + "resolved": "https://registry.npmjs.org/nanoid/-/nanoid-3.3.6.tgz", + "integrity": "sha512-BGcqMMJuToF7i1rt+2PWSNVnWIkGCU78jBG3RxO/bZlnZPK2Cmi2QaffxGO/2RvWi9sL+FAiRiXMgsyxQ1DIDA==", "dev": true } } @@ -13163,6 +13203,12 @@ "resolved": "https://registry.npmjs.org/source-map/-/source-map-0.7.4.tgz", "integrity": "sha512-l3BikUxvPOcn5E74dZiq5BGsTb5yEwhaTSzccU6t4sDOH8NWJCstKO5QT2CvtFoK6F0saL7p9xHAqHOlCPJygA==" }, + "source-map-js": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/source-map-js/-/source-map-js-1.0.2.tgz", + "integrity": "sha512-R0XvVJ9WusLiqTCEiGCmICCMplcCkIwwR11mOSD9CR5u+IXYdiseeEuXCVAjS54zqwkLcPNnmU4OeJ6tUrWhDw==", + "dev": true + }, "source-map-support": { "version": "0.5.19", "resolved": "https://registry.npmjs.org/source-map-support/-/source-map-support-0.5.19.tgz", diff --git a/src/BsConfig.ts b/src/BsConfig.ts index 9fe4389bf..ca0c9d5c6 100644 --- a/src/BsConfig.ts +++ b/src/BsConfig.ts @@ -12,6 +12,16 @@ export interface BsConfig { */ project?: string; + manifest?: { + bs_const?: Record; + }; + + /** + * when set, bsconfig.json loading is disabled + */ + noProject?: boolean; + + /** * Relative or absolute path to another bsconfig.json file that this file should import and then override. * Prefix with a question mark (?) to prevent throwing an exception if the file does not exist. @@ -105,7 +115,7 @@ export interface BsConfig { /** * Emit type definition files (`d.bs`) - * @default true + * @default false */ emitDefinitions?: boolean; @@ -169,4 +179,12 @@ export interface BsConfig { * @default false */ allowBrighterScriptInBrightScript?: boolean; + + /** + * Override the destination directory for the bslib.brs file. Use this if + * you want to customize where the bslib.brs file is located in the staging + * directory. Note that using a location outside of `source` will break + * scripts inside `source` that depend on bslib.brs. Defaults to `source`. + */ + bslibDestinationDir?: string; } diff --git a/src/Program.spec.ts b/src/Program.spec.ts index 5327ff22e..6ade1688c 100644 --- a/src/Program.spec.ts +++ b/src/Program.spec.ts @@ -1191,6 +1191,18 @@ describe('Program', () => { expect(fsExtra.pathExistsSync(s`${stagingDir}/source/bslib.brs`)).is.true; }); + it('copies the bslib.brs file to optionally specified directory', async () => { + fsExtra.ensureDirSync(program.options.stagingDir); + program.options.bslibDestinationDir = 'source/opt'; + program.validate(); + + await program.build({ + stagingDir: program.options.stagingDir + }); + + expect(fsExtra.pathExistsSync(s`${stagingDir}/source/opt/bslib.brs`)).is.true; + }); + describe('getTranspiledFileContents', () => { it('fires plugin events', async () => { const file = program.setFile('source/main.brs', trim` @@ -1466,6 +1478,26 @@ describe('Program', () => { `); }); + it('uses custom bslib path when specified in .xml file', async () => { + program.options.bslibDestinationDir = 'source/opt'; + program.setFile('components/Component1.xml', trim` + + + + `); + await program.build({ + stagingDir: program.options.stagingDir + }); + expect(trimMap( + fsExtra.readFileSync(s`${stagingDir}/components/Component1.xml`).toString() + )).to.eql(trim` + + +