Skip to content
Merged
Show file tree
Hide file tree
Changes from 11 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 4 additions & 9 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -150,24 +150,20 @@ If you need to configure `bsc`, you can do so in two ways:
1. Your project resides in a subdirectory of your workspace folder.

```bash
bsc --root-dir ./rokuSourceFiles
bsc --rootDir ./rokuSourceFiles
```
2. Run the compiler in watch mode

```bash
bsc --watch
```

3. Run the compiler in watch mode, and redeploy to the roku on every change
```bash
bsc --watch --deploy --host 192.168.1.10 --password secret_password
```
4. Use a bsconfig.json file not located at cwd
3. Use a bsconfig.json file not located at cwd
```bash
bsc --project ./some_folder/bsconfig.json
```

5. Run the compiler as a **linter** only (watch mode supported)
4. Run the compiler as a **linter** only (watch mode supported)
```bash
bsc --create-package false --copy-to-staging false
```
Expand All @@ -183,8 +179,7 @@ The presence of a `bsconfig.json` file in a directory indicates that the directo
"files": [
"**/*"
],
"stagingFolderPath": "dist",
"retainStagingFolder": true,
"outDir": "out",
//this flag tells BrighterScript that for every xml file, try to import a .bs file with the same name and location
"autoImportComponentScript": true,
"sourceMap": true
Expand Down
6 changes: 4 additions & 2 deletions benchmarks/targets/lex-parse-validate.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import type { BsConfig } from '../../src';
import type { TargetOptions } from '../target-runner';
import * as fsExtra from 'fs-extra';

Expand Down Expand Up @@ -26,12 +27,13 @@ module.exports = (options: TargetOptions) => {
cwd: projectPath,
createPackage: false,
copyToStaging: false,
noEmit: true,
//disable diagnostic reporting (they still get collected)
diagnosticFilters: ['**/*'],
logLevel: 'error',
...options.additionalConfig
}).then(() => {
if (Object.keys(builder.program.files).length === 0) {
} as BsConfig & Record<string, any>).then(() => {
if (Object.keys(builder.program!.files).length === 0) {
throw new Error('No files found in program');
} else {
deferred.resolve();
Expand Down
7 changes: 5 additions & 2 deletions benchmarks/targets/lex.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import type { BsConfig } from '../../src';
import type { BrsFile } from '../../src/files/BrsFile';
import type { TargetOptions } from '../target-runner';

module.exports = async (options: TargetOptions) => {
Expand All @@ -10,13 +12,14 @@ module.exports = async (options: TargetOptions) => {
cwd: projectPath,
createPackage: false,
copyToStaging: false,
noEmit: true,
//disable diagnostic reporting (they still get collected)
diagnosticFilters: ['**/*'],
logLevel: 'error',
...options.additionalConfig
});
} as BsConfig & Record<string, any>);
//collect all the brighterscript files
const brsFiles = Object.values(builder.program.files).filter(x => x.extension === '.brs' || x.extension === '.bs');
const brsFiles = Object.values(builder.program!.files as Record<string, BrsFile>).filter(x => x.extension === '.brs' || x.extension === '.bs');
if (brsFiles.length === 0) {
throw new Error('No files found in program');
}
Expand Down
10 changes: 6 additions & 4 deletions benchmarks/targets/parse-brs.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import type { BsConfig } from '../../src';
import type { TargetOptions } from '../target-runner';

module.exports = async (options: TargetOptions) => {
Expand All @@ -10,13 +11,14 @@ module.exports = async (options: TargetOptions) => {
cwd: projectPath,
createPackage: false,
copyToStaging: false,
noEmit: true,
//disable diagnostic reporting (they still get collected)
diagnosticFilters: ['**/*'],
logLevel: 'error',
...options.additionalConfig
});
} as BsConfig & Record<string, any>);
//collect all the brs file contents
const files = Object.values(builder.program.files).filter(x => ['.brs', '.bs', '.d.bs'].includes(brighterscript.util.getExtension(x.srcPath)!)).map(x => ({
const files = Object.values(builder.program!.files).filter(x => ['.brs', '.bs', '.d.bs'].includes(brighterscript.util.getExtension(x.srcPath)!)).map(x => ({
destPath: x.destPath ?? x.pkgPath,
fileContents: (x as any).fileContents
}));
Expand All @@ -25,13 +27,13 @@ module.exports = async (options: TargetOptions) => {
return;
}

const setFileFuncName = builder.program['setFile'] ? 'setFile' : 'addOrReplaceFile';
const setFileFuncName = builder.program!['setFile'] ? 'setFile' : 'addOrReplaceFile';

suite.add(fullName, (deferred) => {
const promises: unknown[] = [];
for (const file of files) {
promises.push(
builder.program[setFileFuncName](file.destPath, file.fileContents)
builder.program![setFileFuncName](file.destPath, file.fileContents)
);
}
// eslint-disable-next-line @typescript-eslint/no-floating-promises
Expand Down
8 changes: 5 additions & 3 deletions benchmarks/targets/parse-xml.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import type { BsConfig } from '../../src';
import type { TargetOptions } from '../target-runner';

module.exports = async (options: TargetOptions) => {
Expand All @@ -10,13 +11,14 @@ module.exports = async (options: TargetOptions) => {
cwd: projectPath,
createPackage: false,
copyToStaging: false,
noEmit: true,
//disable diagnostic reporting (they still get collected)
diagnosticFilters: ['**/*'],
logLevel: 'error',
...options.additionalConfig
});
} as BsConfig & Record<string, any>);
//collect all the XML file contents
const xmlFiles = Object.values(builder.program.files).filter(x => (x as any)?.extension === '.xml').map(x => ({
const xmlFiles = Object.values(builder.program!.files).filter(x => (x as any)?.extension === '.xml').map(x => ({
srcPath: x.srcPath ?? (x as any).pathAbsolute,
pkgPath: x.pkgPath,
fileContents: (x as any).fileContents
Expand All @@ -28,7 +30,7 @@ module.exports = async (options: TargetOptions) => {
suite.add(fullName, (deferred) => {
const wait: Promise<any>[] = [];
for (const x of xmlFiles) {
let xmlFile = new XmlFile({ srcPath: x.srcPath, destPath: (x as any)?.destPath ?? x.pkgPath, program: builder.program });
let xmlFile = new XmlFile({ srcPath: x.srcPath, destPath: (x as any)?.destPath ?? x.pkgPath, program: builder.program as any });
if (typeof xmlFile.srcPath !== 'string') {
//fallback to legacy constructor signature
xmlFile = (XmlFile as any)(x.srcPath, x.pkgPath, builder.program);
Expand Down
7 changes: 4 additions & 3 deletions benchmarks/targets/parse.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import type { BrsFile } from '../../src/files/BrsFile';
import type { BrsFile, BsConfig } from '../../src';
import type { TargetOptions } from '../target-runner';

module.exports = async (options: TargetOptions) => {
Expand All @@ -11,13 +11,14 @@ module.exports = async (options: TargetOptions) => {
cwd: projectPath,
createPackage: false,
copyToStaging: false,
noEmit: true,
//disable diagnostic reporting (they still get collected)
diagnosticFilters: ['**/*'],
logLevel: 'error',
...options.additionalConfig
});
} as BsConfig & Record<string, any>);
//collect all the brighterscript files
const brsFiles = Object.values(builder.program.files).filter(x => x.extension === '.brs' || x.extension === '.bs') as Array<BrsFile>;
const brsFiles = Object.values(builder.program!.files as Record<string, BrsFile>).filter(x => x.extension === '.brs' || x.extension === '.bs') as Array<BrsFile>;
if (brsFiles.length === 0) {
throw new Error('No files found in program');
}
Expand Down
6 changes: 4 additions & 2 deletions benchmarks/targets/transpile-brs.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import type { BrsFile, BsConfig } from '../../src';
import type { TargetOptions } from '../target-runner';

module.exports = async (options: TargetOptions) => {
Expand All @@ -10,13 +11,14 @@ module.exports = async (options: TargetOptions) => {
cwd: projectPath,
createPackage: false,
copyToStaging: false,
noEmit: true,
//disable diagnostic reporting (they still get collected)
diagnosticFilters: ['**/*'],
logLevel: 'error',
...options.additionalConfig
});
} as BsConfig & Record<string, any>);
//collect all the brs files
const files = Object.values(builder.program.files).filter(x => ['.brs', '.bs'].includes(x.extension));
const files = Object.values(builder.program!.files as Record<string, BrsFile>).filter(x => ['.brs', '.bs'].includes(x.extension));

//flag every file for transpilation
for (const file of files) {
Expand Down
6 changes: 4 additions & 2 deletions benchmarks/targets/transpile-xml.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import type { BrsFile, BsConfig } from '../../src';
import type { TargetOptions } from '../target-runner';

module.exports = async (options: TargetOptions) => {
Expand All @@ -10,13 +11,14 @@ module.exports = async (options: TargetOptions) => {
cwd: projectPath,
createPackage: false,
copyToStaging: false,
noEmit: true,
//disable diagnostic reporting (they still get collected)
diagnosticFilters: ['**/*'],
logLevel: 'error',
...options.additionalConfig
});
} as BsConfig & Record<string, any>);
//collect all the XML files
const files = Object.values(builder.program.files).filter(x => x.extension === '.xml');
const files = Object.values(builder.program!.files as Record<string, BrsFile>).filter(x => x.extension === '.xml');
//flag every file for transpilation
for (const file of files) {
file.needsTranspiled = true;
Expand Down
8 changes: 5 additions & 3 deletions benchmarks/targets/transpile.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import type { BrsFile, BsConfig } from '../../src';
import type { TargetOptions } from '../target-runner';

module.exports = async (options: TargetOptions) => {
Expand All @@ -10,16 +11,17 @@ module.exports = async (options: TargetOptions) => {
cwd: projectPath,
createPackage: false,
copyToStaging: false,
noEmit: true,
//disable diagnostic reporting (they still get collected)
diagnosticFilters: ['**/*'],
logLevel: 'error',
...options.additionalConfig
});
if (Object.keys(builder.program.files).length === 0) {
} as BsConfig & Record<string, any>);
if (Object.keys(builder.program!.files).length === 0) {
throw new Error('No files found in program');
}

const files = Object.values(builder.program.files);
const files = Object.values(builder.program!.files) as Array<BrsFile>;

//force transpile for every file
for (const file of files) {
Expand Down
10 changes: 6 additions & 4 deletions benchmarks/targets/validate.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import type { BsConfig } from '../../src';
import type { TargetOptions } from '../target-runner';

module.exports = async (options: TargetOptions) => {
Expand All @@ -10,23 +11,24 @@ module.exports = async (options: TargetOptions) => {
cwd: projectPath,
createPackage: false,
copyToStaging: false,
noEmit: true,
//disable diagnostic reporting (they still get collected)
diagnosticFilters: ['**/*'],
logLevel: 'error',
...options.additionalConfig
} as any);
if (Object.keys(builder.program.files).length === 0) {
} as BsConfig & Record<string, any>);
if (Object.keys(builder.program!.files).length === 0) {
throw new Error('No files found in program');
}

suite.add(fullName, (deferred) => {
const scopes = Object.values(builder.program['scopes']);
const scopes = Object.values(builder.program!['scopes']);
//mark all scopes as invalid so they'll re-validate
for (let scope of scopes) {
scope.invalidate();
}
Promise.resolve(
builder.program.validate()
builder.program!.validate()
).finally(() => deferred.resolve());
}, {
...suiteOptions,
Expand Down
33 changes: 28 additions & 5 deletions bsconfig.schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,8 @@
},
"outFile": {
"description": "The path where the output zip or package should be placed. This includes the filename. Defaults to \"./out/package\"",
"deprecated": true,
"deprecationMessage": "Deprecated in v1",
"type": "string"
},
"createPackage": {
Expand All @@ -101,6 +103,12 @@
},
"copyToStaging": {
"description": "If true, the files are copied to staging. This setting is ignored when deploy is enabled or if createPackage is enabled",
"deprecated": true,
"deprecationMessage": "Deprecated. Use `noEmit` instead.",
"type": "boolean"
},
"noEmit": {
"description": "If true, then no files are copied to outDir.",
"type": "boolean"
},
"watch": {
Expand All @@ -109,19 +117,27 @@
"default": false
},
"deploy": {
"description": "If true, after a successful build, the project will be deployed to the roku specified in host",
"description": "If true, after a successful buld, the project will be deployed to the roku specified in host",
"deprecated": true,
"deprecationMessage": "Deprecated. No longer supporting deployment in this tool.",
"type": "boolean"
},
"host": {
"description": "The host of the Roku that the package will be deploy to",
"description": "host of the Roku that the package will be deploy to",
"deprecated": true,
"deprecationMessage": "Deprecated. No longer supporting deployment in this tool.",
"type": "string"
},
"username": {
"description": "The username to use when deploying to a Roku device",
"deprecated": true,
"deprecationMessage": "Deprecated. No longer supporting deployment in this tool.",
"type": "string"
},
"password": {
"description": " The password to use when deploying to a Roku device",
"description": "The password to use when deploying to a Roku device",
"deprecated": true,
"deprecationMessage": "Deprecated. No longer supporting deployment in this tool.",
"type": "string"
},
"retainStagingDir": {
Expand All @@ -133,16 +149,23 @@
"type": "boolean",
"deprecated": true,
"description": "Prevent the staging folder from being deleted after the deployment package is created. This is helpful for troubleshooting why your package isn't being created the way you expected.",
"deprecationMessage": "Deprecated. No longer supporting package zipping in this tool.",
"default": false
},
"stagingDir": {
"type": "string",
"deprecated": true,
"deprecationMessage": "Deprecated. Use `outDir` instead.",
"description": "The path to the staging folder (where all files are copied before creating the zip package)"
},
"outDir": {
"type": "string",
"description": "TODO better description: The path to the output directory (where all files are copied before creating the zip package)"
},
"stagingFolderPath": {
"type": "string",
"deprecated": true,
"deprecationMessage": "Deprecated. Use `stagingDir` instead.",
"deprecationMessage": "Deprecated. Use `outDir` instead.",
"description": "The path to the staging folder (where all files are copied before creating the zip package)"
},
"ignoreErrorCodes": {
Expand Down Expand Up @@ -311,4 +334,4 @@
"default": false
}
}
}
}
Loading
Loading