From 63d3b7e7410326977e99dbbbad1ec7526688f389 Mon Sep 17 00:00:00 2001 From: Milap Naik Date: Mon, 4 Dec 2023 20:18:59 +0100 Subject: [PATCH] Remove retain staging folder which was deprecated (#130) * Rough draft of adding individual interfaces * variable name changes for different options * Make all changes except a few that are questionable * Take out warning since rootDir defaults * Make variable optional * Make rootDir mandatory, fixes 8 failing tests * make stagingDir mandatory for zip package, fixes 1 test * forgot 2 lines from last commit message * Fix 1 more test * Make outfile mandatory in publishOptions, fixes 12 tests * fix 1 more test over copying mistake * added stagingDir to prepublishToStaging tests to get 10 more tests to pass, all are passing now * Changed a few more interfaces that I had forgotten * Attempt to debug github tests * Test was fixed on github * Fix missing coverage * delete retainStagingFolder --------- Co-authored-by: Bronley Plumb --- README.md | 2 +- src/RokuDeploy.spec.ts | 21 +++------------------ src/RokuDeploy.ts | 33 +++++++++++++++------------------ src/RokuDeployOptions.ts | 7 ------- 4 files changed, 19 insertions(+), 44 deletions(-) diff --git a/README.md b/README.md index ca6a6bd..42bcc26 100644 --- a/README.md +++ b/README.md @@ -360,7 +360,7 @@ Here are the available options. The defaults are shown to the right of the optio *NOTE:* If you override this "files" property, you need to provide **all** config values, as your array will completely overwrite the default. -- **retainStagingFolder?:** boolean = `false` +- **retainStagingDir?:** boolean = `false` Set this to true to prevent the staging folder from being deleted after creating the package. This is helpful for troubleshooting why your package isn't being created the way you expected. - **stagingDir?:** string = `` `${options.outDir}/.roku-deploy-staging` `` diff --git a/src/RokuDeploy.spec.ts b/src/RokuDeploy.spec.ts index 36f675c..f7027c8 100644 --- a/src/RokuDeploy.spec.ts +++ b/src/RokuDeploy.spec.ts @@ -1748,7 +1748,7 @@ describe('index', () => { 'manifest', 'components/!(scenes)/**/*' ], - retainStagingFolder: true, + retainStagingDir: true, rootDir: rootDir, stagingDir: stagingDir }); @@ -1770,7 +1770,7 @@ describe('index', () => { 'components/**/*', '!components/scenes/**/*' ], - retainStagingFolder: true, + retainStagingDir: true, rootDir: rootDir, stagingDir: stagingDir }); @@ -1785,7 +1785,7 @@ describe('index', () => { 'manifest', {} ], - retainStagingFolder: true, + retainStagingDir: true, rootDir: rootDir, stagingDir: stagingDir }); @@ -3520,21 +3520,6 @@ describe('index', () => { ).to.eql(s`${cwd}/staging-folder-path`); }); - it('supports deprecated retainStagingFolder option', () => { - sinon.stub(fsExtra, 'existsSync').callsFake((filePath) => { - return false; - }); - expect( - rokuDeploy.getOptions({ retainStagingFolder: true }).retainStagingDir - ).to.be.true; - expect( - rokuDeploy.getOptions({ retainStagingFolder: true, retainStagingDir: false }).retainStagingDir - ).to.be.false; - expect( - rokuDeploy.getOptions({ retainStagingFolder: true, retainStagingDir: false }).retainStagingFolder - ).to.be.false; - }); - it('calling with no parameters works', () => { sinon.stub(fsExtra, 'existsSync').callsFake((filePath) => { return false; diff --git a/src/RokuDeploy.ts b/src/RokuDeploy.ts index 41fc690..38ca6f8 100644 --- a/src/RokuDeploy.ts +++ b/src/RokuDeploy.ts @@ -111,7 +111,7 @@ export class RokuDeploy { //make sure the output folder exists await this.fsExtra.ensureDir(options.outDir); - let zipFilePath = this.getOutputZipFilePath(options); + let zipFilePath = this.getOutputZipFilePath(options as any); //ensure the manifest file exists in the staging folder if (!await util.fileExistsCaseInsensitive(`${options.stagingDir}/manifest`)) { @@ -418,7 +418,7 @@ export class RokuDeploy { //make sure the outDir exists await this.fsExtra.ensureDir(options.outDir); - let zipFilePath = this.getOutputZipFilePath(options); + let zipFilePath = this.getOutputZipFilePath(options as any); let readStream: _fsExtra.ReadStream; try { if ((await this.fsExtra.pathExists(zipFilePath)) === false) { @@ -430,7 +430,7 @@ export class RokuDeploy { readStream.on('open', resolve); }); - let requestOptions = this.generateBaseRequestOptions('plugin_install', options, { + let requestOptions = this.generateBaseRequestOptions('plugin_install', options as any, { mysubmit: 'Replace', archive: readStream }); @@ -500,7 +500,7 @@ export class RokuDeploy { if (!options.host) { throw new errors.MissingRequiredOptionError('must specify the host for the Roku device'); } - let requestOptions = this.generateBaseRequestOptions('plugin_install', options, { + let requestOptions = this.generateBaseRequestOptions('plugin_install', options as any, { archive: '', mysubmit: 'Convert to squashfs' }); @@ -529,7 +529,7 @@ export class RokuDeploy { if (!path.isAbsolute(options.rekeySignedPackage)) { rekeySignedPackagePath = path.join(options.rootDir, options.rekeySignedPackage); } - let requestOptions = this.generateBaseRequestOptions('plugin_inspect', options, { + let requestOptions = this.generateBaseRequestOptions('plugin_inspect', options as any, { mysubmit: 'Rekey', passwd: options.signingPassword, archive: null as _fsExtra.ReadStream @@ -577,7 +577,7 @@ export class RokuDeploy { let parsedManifest = await this.parseManifest(manifestPath); let appName = parsedManifest.title + '/' + parsedManifest.major_version + '.' + parsedManifest.minor_version; - let requestOptions = this.generateBaseRequestOptions('plugin_package', options, { + let requestOptions = this.generateBaseRequestOptions('plugin_package', options as any, { mysubmit: 'Package', pkg_time: (new Date()).getTime(), //eslint-disable-line camelcase passwd: options.signingPassword, @@ -608,7 +608,7 @@ export class RokuDeploy { options = this.getOptions(options) as any; let requestOptions = this.generateBaseRequestOptions(pkgPath, options); - let pkgFilePath = this.getOutputPkgFilePath(options); + let pkgFilePath = this.getOutputPkgFilePath(options as any); return this.getToFile(requestOptions, pkgFilePath); } @@ -767,7 +767,7 @@ export class RokuDeploy { // note we don't report the error; as we don't actually care that we could not deploy - it's just useless noise to log it. } } - let result = await this.publish(options); + let result = await this.publish(options as any); return result; } @@ -778,7 +778,7 @@ export class RokuDeploy { public async deleteInstalledChannel(options?: DeleteInstalledChannelOptions) { options = this.getOptions(options) as any; - let deleteOptions = this.generateBaseRequestOptions('plugin_install', options); + let deleteOptions = this.generateBaseRequestOptions('plugin_install', options as any); deleteOptions.formData = { mysubmit: 'Delete', archive: '' @@ -796,7 +796,7 @@ export class RokuDeploy { // Ask for the device to make an image let createScreenshotResult = await this.doPostRequest({ - ...this.generateBaseRequestOptions('plugin_inspect', options), + ...this.generateBaseRequestOptions('plugin_inspect', options as any), formData: { mysubmit: 'Screenshot', archive: '' @@ -861,14 +861,14 @@ export class RokuDeploy { options = this.getOptions(options) as any; let retainStagingDirInitialValue = options.retainStagingDir; options.retainStagingDir = true; - await this.deploy(options, beforeZipCallback); + await this.deploy(options as any, beforeZipCallback); if (options.convertToSquashfs) { - await this.convertToSquashfs(options); + await this.convertToSquashfs(options as any); } - let remotePkgPath = await this.signExistingPackage(options); - let localPkgFilePath = await this.retrieveSignedPackage(remotePkgPath, options); + let remotePkgPath = await this.signExistingPackage(options as any); + let localPkgFilePath = await this.retrieveSignedPackage(remotePkgPath, options as any); if (retainStagingDirInitialValue !== true) { await this.fsExtra.remove(options.stagingDir); } @@ -933,9 +933,6 @@ export class RokuDeploy { //fully resolve the folder paths finalOptions.rootDir = path.resolve(process.cwd(), finalOptions.rootDir); finalOptions.outDir = path.resolve(process.cwd(), finalOptions.outDir); - finalOptions.retainStagingDir = (finalOptions.retainStagingDir !== undefined) ? finalOptions.retainStagingDir : finalOptions.retainStagingFolder; - //sync the new option with the old one (for back-compat) - finalOptions.retainStagingFolder = finalOptions.retainStagingDir; let stagingDir = finalOptions.stagingDir || finalOptions.stagingFolderPath; @@ -1256,7 +1253,7 @@ export interface PrepublishToStagingOptions { rootDir?: string; files?: FileEntry[]; stagingDir?: string; - retainStagingFolder?: boolean; + retainStagingDir?: boolean; } export interface ZipPackageOptions { diff --git a/src/RokuDeployOptions.ts b/src/RokuDeployOptions.ts index 75e4378..b05a5b4 100644 --- a/src/RokuDeployOptions.ts +++ b/src/RokuDeployOptions.ts @@ -37,13 +37,6 @@ export interface RokuDeployOptions { */ files?: FileEntry[]; - /** - * Set this to true to prevent the staging folder from being deleted after creating the package - * @default false - * @deprecated use `retainStagingDir` instead - */ - retainStagingFolder?: boolean; - /** * Set this to true to prevent the staging folder from being deleted after creating the package * @default false