From 5a36a718969224c4099550a048193791f50a5146 Mon Sep 17 00:00:00 2001 From: philanderson888 Date: Wed, 2 Aug 2023 08:08:15 +0200 Subject: [PATCH 1/4] initial commit --- src/BsConfig.ts | 7 +++++++ src/ProgramBuilder.ts | 2 ++ src/cli.ts | 6 ++++++ src/util.ts | 11 ++++++----- 4 files changed, 21 insertions(+), 5 deletions(-) diff --git a/src/BsConfig.ts b/src/BsConfig.ts index 40fd49cc9..07fc03375 100644 --- a/src/BsConfig.ts +++ b/src/BsConfig.ts @@ -12,6 +12,13 @@ export interface BsConfig { */ project?: string; + /** + * An optional parameter + * When value is set to 'true' and 'project' is null, no bsconfig.json is expected + */ + 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. diff --git a/src/ProgramBuilder.ts b/src/ProgramBuilder.ts index 8808d59dc..077636e85 100644 --- a/src/ProgramBuilder.ts +++ b/src/ProgramBuilder.ts @@ -100,6 +100,8 @@ export class ProgramBuilder { this.options = util.normalizeAndResolveConfig(options); if (this.options.project) { this.logger.log(`Using config file: "${this.options.project}"`); + } else if (this.options.noProject) { + this.logger.log(`No bsconfig.json file expected because using flag --noProject`); } else { this.logger.log(`No bsconfig.json file found, using default options`); } diff --git a/src/cli.ts b/src/cli.ts index 6a23b2d19..b5349c9b4 100644 --- a/src/cli.ts +++ b/src/cli.ts @@ -30,6 +30,7 @@ let options = yargs .option('files', { type: 'array', description: 'The list of files (or globs) to include in your project. Be sure to wrap these in double quotes when using globs.' }) .option('host', { type: 'string', description: 'The host used when deploying to a Roku.' }) .option('ignore-error-codes', { type: 'array', description: 'A list of error codes that the compiler should NOT emit, even if encountered.' }) + .option('no-project', { type: 'boolean', defaultDescription: 'false', description: 'when flag set and also project path is null, no bsconfig.json is expected' }) .option('log-level', { type: 'string', defaultDescription: '"log"', description: 'The log level. Value can be "error", "warn", "log", "info", "debug".' }) .option('out-file', { type: 'string', description: 'Path to the zip folder containing the bundled project. Defaults to `./out/[YOUR_ROOT_FOLDER_NAME].zip' }) .option('password', { type: 'string', description: 'The password for deploying to a Roku.' }) @@ -62,6 +63,11 @@ async function main() { try { initProfiling(); + console.log('main()'); + + console.log('options ...'); + console.log(options); + if (options.lsp) { const server = new LanguageServer(); server.run(); diff --git a/src/util.ts b/src/util.ts index a7817f141..2dd101824 100644 --- a/src/util.ts +++ b/src/util.ts @@ -297,12 +297,13 @@ export class Util { public normalizeAndResolveConfig(config: BsConfig) { let result = this.normalizeConfig({}); - //if no options were provided, try to find a bsconfig.json file - if (!config || !config.project) { - result.project = this.getConfigFilePath(config?.cwd); + result.project = null; + if (config?.project) { + result.project = config?.project; } else { - //use the config's project link - result.project = config.project; + if (config?.cwd) { + result.project = this.getConfigFilePath(config?.cwd); + } } if (result.project) { let configFile = this.loadConfigFile(result.project, null, config?.cwd); From 01165a5ab19207ab20377be2552bebc96c41e55f Mon Sep 17 00:00:00 2001 From: philanderson888 Date: Mon, 7 Aug 2023 12:48:25 +0100 Subject: [PATCH 2/4] update comments --- src/BsConfig.ts | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/BsConfig.ts b/src/BsConfig.ts index 07fc03375..8f78276cc 100644 --- a/src/BsConfig.ts +++ b/src/BsConfig.ts @@ -13,8 +13,7 @@ export interface BsConfig { project?: string; /** - * An optional parameter - * When value is set to 'true' and 'project' is null, no bsconfig.json is expected + * when set, bsconfig.json loading is disabled */ noProject?: boolean; From f48fc63cb5ea1b3c6dd83fe6151edaac11adf7ff Mon Sep 17 00:00:00 2001 From: philanderson888 Date: Mon, 7 Aug 2023 12:53:10 +0100 Subject: [PATCH 3/4] update code to match suggested comments --- src/ProgramBuilder.ts | 6 +++--- src/cli.ts | 2 +- src/util.ts | 4 ++++ 3 files changed, 8 insertions(+), 4 deletions(-) diff --git a/src/ProgramBuilder.ts b/src/ProgramBuilder.ts index 3162b3557..434cb5ad9 100644 --- a/src/ProgramBuilder.ts +++ b/src/ProgramBuilder.ts @@ -99,10 +99,10 @@ export class ProgramBuilder { this.isRunning = true; try { this.options = util.normalizeAndResolveConfig(options); - if (this.options.project) { + if (this.options.noProject) { + this.logger.log(`'no-project' flag is set so bsconfig.json loading is disabled'`); + } else if (this.options.project) { this.logger.log(`Using config file: "${this.options.project}"`); - } else if (this.options.noProject) { - this.logger.log(`No bsconfig.json file expected because using flag --noProject`); } else { this.logger.log(`No bsconfig.json file found, using default options`); } diff --git a/src/cli.ts b/src/cli.ts index b5349c9b4..6565ae8d9 100644 --- a/src/cli.ts +++ b/src/cli.ts @@ -30,7 +30,7 @@ let options = yargs .option('files', { type: 'array', description: 'The list of files (or globs) to include in your project. Be sure to wrap these in double quotes when using globs.' }) .option('host', { type: 'string', description: 'The host used when deploying to a Roku.' }) .option('ignore-error-codes', { type: 'array', description: 'A list of error codes that the compiler should NOT emit, even if encountered.' }) - .option('no-project', { type: 'boolean', defaultDescription: 'false', description: 'when flag set and also project path is null, no bsconfig.json is expected' }) + .option('no-project', { type: 'boolean', defaultDescription: 'false', description: 'When set, bsconfig.json loading is disabled', alias: ['noproject', 'noProject'] }) .option('log-level', { type: 'string', defaultDescription: '"log"', description: 'The log level. Value can be "error", "warn", "log", "info", "debug".' }) .option('out-file', { type: 'string', description: 'Path to the zip folder containing the bundled project. Defaults to `./out/[YOUR_ROOT_FOLDER_NAME].zip' }) .option('password', { type: 'string', description: 'The password for deploying to a Roku.' }) diff --git a/src/util.ts b/src/util.ts index 368e11c48..32cf24943 100644 --- a/src/util.ts +++ b/src/util.ts @@ -297,6 +297,10 @@ export class Util { public normalizeAndResolveConfig(config: BsConfig) { let result = this.normalizeConfig({}); + if (config?.noProject) { + return result; + } + result.project = null; if (config?.project) { result.project = config?.project; From 18499897e51a71274cd34aa9e571d349e29fcc4c Mon Sep 17 00:00:00 2001 From: philanderson888 Date: Mon, 7 Aug 2023 12:54:36 +0100 Subject: [PATCH 4/4] remove developer logging --- src/cli.ts | 5 ----- 1 file changed, 5 deletions(-) diff --git a/src/cli.ts b/src/cli.ts index 6565ae8d9..378d9983c 100644 --- a/src/cli.ts +++ b/src/cli.ts @@ -63,11 +63,6 @@ async function main() { try { initProfiling(); - console.log('main()'); - - console.log('options ...'); - console.log(options); - if (options.lsp) { const server = new LanguageServer(); server.run();