Skip to content

Commit

Permalink
Use stagingDir instead of stagingFolderPath (#185)
Browse files Browse the repository at this point in the history
  • Loading branch information
TwitchBronBron authored Jan 19, 2024
1 parent dec7881 commit 7e28fdb
Show file tree
Hide file tree
Showing 9 changed files with 121 additions and 114 deletions.
7 changes: 7 additions & 0 deletions src/LaunchConfiguration.ts
Original file line number Diff line number Diff line change
Expand Up @@ -260,9 +260,16 @@ export interface LaunchConfiguration extends DebugProtocol.LaunchRequestArgument
/**
* The path used for the staging folder of roku-deploy
* This should generally be set to "${cwd}/.roku-deploy-staging", but that's ultimately up to the debug client.
* @deprecated use `stagingDir` instead
*/
stagingFolderPath?: string;

/**
* Path used for the staging folder where files are written right before being packaged. This folder will contain any roku-debug related sourcemaps,
* as well as having breakpoints injected into source code
*/
stagingDir?: string;

/**
* What level of debug server's internal logging should be performed in the debug session
*/
Expand Down
10 changes: 5 additions & 5 deletions src/debugSession/BrightScriptDebugSession.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ describe('BrightScriptDebugSession', () => {
launchConfiguration = {
rootDir: rootDir,
outDir: outDir,
stagingFolderPath: stagingDir,
stagingDir: stagingDir,
files: DefaultFiles
} as any;
session['launchConfiguration'] = launchConfiguration;
Expand Down Expand Up @@ -658,7 +658,7 @@ describe('BrightScriptDebugSession', () => {
it('registers the entry breakpoint when stopOnEntry is enabled', async () => {
(session as any).launchConfiguration = { stopOnEntry: true };
session.projectManager.mainProject = <any>{
stagingFolderPath: stagingDir
stagingDir: stagingDir
};
let stub = sinon.stub(session.projectManager, 'registerEntryBreakpoint').returns(Promise.resolve());
await session.handleEntryBreakpoint();
Expand All @@ -677,10 +677,10 @@ describe('BrightScriptDebugSession', () => {
it('erases all staging folders when configured to do so', async () => {
let stub = sinon.stub(fsExtra, 'removeSync').returns(null);
session.projectManager.mainProject = <any>{
stagingFolderPath: 'stagingPathA'
stagingDir: 'stagingPathA'
};
session.projectManager.componentLibraryProjects.push(<any>{
stagingFolderPath: 'stagingPathB'
stagingDir: 'stagingPathB'
});
(session as any).launchConfiguration = {
retainStagingFolder: false
Expand Down Expand Up @@ -830,7 +830,7 @@ describe('BrightScriptDebugSession', () => {
session.projectManager.componentLibraryProjects.push(
new ComponentLibraryProject({
rootDir: complib1Dir,
stagingFolderPath: stagingDir,
stagingDir: stagingDir,
outDir: outDir,
libraryIndex: 1
} as Partial<ComponentLibraryConstructorParams> as any)
Expand Down
15 changes: 8 additions & 7 deletions src/debugSession/BrightScriptDebugSession.ts
Original file line number Diff line number Diff line change
Expand Up @@ -229,6 +229,7 @@ export class BrightScriptDebugSession extends BaseDebugSession {
config.sceneGraphDebugCommandsPort ??= 8080;
config.controlPort ??= 8081;
config.brightScriptConsolePort ??= 8085;
config.stagingDir ??= config.stagingFolderPath;
return config;
}

Expand Down Expand Up @@ -628,7 +629,7 @@ export class BrightScriptDebugSession extends BaseDebugSession {
raleTrackerTaskFileLocation: this.launchConfiguration.raleTrackerTaskFileLocation,
injectRdbOnDeviceComponent: this.launchConfiguration.injectRdbOnDeviceComponent,
rdbFilesBasePath: this.launchConfiguration.rdbFilesBasePath,
stagingFolderPath: this.launchConfiguration.stagingFolderPath
stagingDir: this.launchConfiguration.stagingDir
});

util.log('Moving selected files to staging area');
Expand Down Expand Up @@ -1439,7 +1440,7 @@ export class BrightScriptDebugSession extends BaseDebugSession {
if (!this.enableDebugProtocol) {
this.entryBreakpointWasHandled = true;
if (this.launchConfiguration.stopOnEntry || this.launchConfiguration.deepLinkUrl) {
await this.projectManager.registerEntryBreakpoint(this.projectManager.mainProject.stagingFolderPath);
await this.projectManager.registerEntryBreakpoint(this.projectManager.mainProject.stagingDir);
}
}
}
Expand Down Expand Up @@ -1468,14 +1469,14 @@ export class BrightScriptDebugSession extends BaseDebugSession {

//if configured, delete the staging directory
if (!this.launchConfiguration.retainStagingFolder) {
const stagingFolders = this.projectManager?.getStagingFolderPaths() ?? [];
this.logger.info('deleting staging folders', stagingFolders);
for (let stagingFolderPath of stagingFolders) {
const stagingDirs = this.projectManager?.getStagingDirs() ?? [];
this.logger.info('deleting staging folders', stagingDirs);
for (let stagingDir of stagingDirs) {
try {
fsExtra.removeSync(stagingFolderPath);
fsExtra.removeSync(stagingDir);
} catch (e) {
this.logger.error(e);
util.log(`Error removing staging directory '${stagingFolderPath}': ${JSON.stringify(e)}`);
util.log(`Error removing staging directory '${stagingDir}': ${JSON.stringify(e)}`);
}
}
}
Expand Down
20 changes: 10 additions & 10 deletions src/managers/BreakpointManager.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -388,7 +388,7 @@ describe('BreakpointManager', () => {
await bpManager.writeBreakpointsForProject(new Project(<any>{
rootDir: rootDir,
outDir: outDir,
stagingFolderPath: stagingDir
stagingDir: stagingDir
}));

//it wrote the breakpoint in the correct location
Expand Down Expand Up @@ -429,7 +429,7 @@ describe('BreakpointManager', () => {
rootDir: rootDir,
outDir: s`${cwd}/out`,
sourceDirs: [sourceDir1],
stagingFolderPath: stagingDir
stagingDir: stagingDir
})
);

Expand Down Expand Up @@ -467,7 +467,7 @@ describe('BreakpointManager', () => {
rootDir: rootDir,
outDir: s`${cwd}/out`,
sourceDirs: [sourceDir1, sourceDir2],
stagingFolderPath: stagingDir
stagingDir: stagingDir
})
);

Expand Down Expand Up @@ -510,7 +510,7 @@ describe('BreakpointManager', () => {
rootDir: rootDir,
outDir: s`${cwd}/out`,
sourceDirs: [sourceDir1, sourceDir2],
stagingFolderPath: stagingDir
stagingDir: stagingDir
})
);

Expand Down Expand Up @@ -552,7 +552,7 @@ describe('BreakpointManager', () => {
rootDir: rootDir,
outDir: s`${cwd}/out`,
sourceDirs: [sourceDir1, sourceDir2],
stagingFolderPath: stagingDir
stagingDir: stagingDir
})
);

Expand Down Expand Up @@ -609,7 +609,7 @@ describe('BreakpointManager', () => {
],
rootDir: s`${tmpDir}/dist`,
outDir: s`${tmpDir}/out`,
stagingFolderPath: stagingDir
stagingDir: stagingDir
}));

//the breakpoints should be placed in the proper locations
Expand Down Expand Up @@ -714,7 +714,7 @@ describe('BreakpointManager', () => {
files: [
'source/main.brs'
],
stagingFolderPath: stagingDir,
stagingDir: stagingDir,
outDir: outDir,
rootDir: rootDir
}));
Expand All @@ -726,7 +726,7 @@ describe('BreakpointManager', () => {
lineNumber: 2,
fileMappings: [],
rootDir: rootDir,
stagingFolderPath: stagingDir,
stagingDir: stagingDir,
enableSourceMaps: true
});

Expand Down Expand Up @@ -775,7 +775,7 @@ describe('BreakpointManager', () => {
files: [
'source/main.brs'
],
stagingFolderPath: stagingDir,
stagingDir: stagingDir,
outDir: outDir,
rootDir: rootDir
}));
Expand Down Expand Up @@ -813,7 +813,7 @@ describe('BreakpointManager', () => {
dest: ''
}
],
stagingFolderPath: stagingDir,
stagingDir: stagingDir,
outDir: outDir,
rootDir: rootDir
});
Expand Down
6 changes: 3 additions & 3 deletions src/managers/BreakpointManager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -368,23 +368,23 @@ export class BreakpointManager {
...project?.sourceDirs ?? [],
project.rootDir
],
project.stagingFolderPath,
project.stagingDir,
project.fileMappings
);

for (let stagingLocation of stagingLocationsResult.locations) {
let relativeStagingPath = fileUtils.replaceCaseInsensitive(
stagingLocation.filePath,
fileUtils.standardizePath(
fileUtils.removeTrailingSlash(project.stagingFolderPath) + '/'
fileUtils.removeTrailingSlash(project.stagingDir) + '/'
),
''
);
const pkgPath = 'pkg:/' + fileUtils
//replace staging folder path with nothing (so we can build a pkg path)
.replaceCaseInsensitive(
s`${stagingLocation.filePath}`,
s`${project.stagingFolderPath}`,
s`${project.stagingDir}`,
''
)
//force to unix path separators
Expand Down
12 changes: 6 additions & 6 deletions src/managers/LocationManager.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ describe('LocationManager', () => {

let location = await locationManager.getSourceLocation({
stagingFilePath: stagingFilePath,
stagingFolderPath: stagingDir,
stagingDir: stagingDir,
fileMappings: [],
rootDir: rootDir,
lineNumber: 1,
Expand All @@ -76,7 +76,7 @@ describe('LocationManager', () => {

let location = await locationManager.getSourceLocation({
stagingFilePath: s`${stagingDir}/lib1.brs`,
stagingFolderPath: stagingDir,
stagingDir: stagingDir,
fileMappings: [{
src: s`${rootDir}/lib1.brs`,
dest: s`${stagingDir}/lib1.brs`
Expand Down Expand Up @@ -116,7 +116,7 @@ describe('LocationManager', () => {

let location = await locationManager.getSourceLocation({
stagingFilePath: stagingFilePath,
stagingFolderPath: stagingDir,
stagingDir: stagingDir,
fileMappings: [],
rootDir: rootDir,
lineNumber: 3,
Expand All @@ -142,7 +142,7 @@ describe('LocationManager', () => {

let location = await locationManager.getSourceLocation({
stagingFilePath: s`${stagingDir}/lib1.brs`,
stagingFolderPath: stagingDir,
stagingDir: stagingDir,
fileMappings: [{
src: s`${sourceDirs[0]}/lib1.brs`,
dest: '/lib1.brs'
Expand All @@ -169,7 +169,7 @@ describe('LocationManager', () => {

let location = await locationManager.getSourceLocation({
stagingFilePath: s`${stagingDir}/lib1.brs`,
stagingFolderPath: stagingDir,
stagingDir: stagingDir,
fileMappings: [{
src: s`${sourceDirs[1]}/lib1.brs`,
dest: '/lib1.brs'
Expand All @@ -195,7 +195,7 @@ describe('LocationManager', () => {

let location = await locationManager.getSourceLocation({
stagingFilePath: s`${stagingDir}/lib1.brs`,
stagingFolderPath: stagingDir,
stagingDir: stagingDir,
fileMappings: [{
src: s`${sourceDirs[2]}/lib1.brs`,
dest: '/lib1.brs'
Expand Down
14 changes: 7 additions & 7 deletions src/managers/LocationManager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ export class LocationManager {
*/
public async getSourceLocation(options: GetSourceLocationOptions): Promise<SourceLocation> {
let rootDir = s`${options.rootDir}`;
let stagingFolderPath = s`${options.stagingFolderPath}`;
let stagingDir = s`${options.stagingDir}`;
let currentFilePath = s`${options.stagingFilePath}`;
let sourceDirs = options.sourceDirs ? options.sourceDirs.map(x => s`${x}`) : [];
//throw out any sourceDirs pointing the rootDir
Expand Down Expand Up @@ -62,7 +62,7 @@ export class LocationManager {
//if we have sourceDirs, rootDir is the project's OUTPUT folder, so skip looking for files there, and
//instead walk backwards through sourceDirs until we find the file we want
if (sourceDirs.length > 0) {
let relativeFilePath = fileUtils.getRelativePath(stagingFolderPath, currentFilePath);
let relativeFilePath = fileUtils.getRelativePath(stagingDir, currentFilePath);
let sourceDirsFilePath = await fileUtils.findFirstRelativeFile(relativeFilePath, sourceDirs);
//if we found a file in one of the sourceDirs, use that
if (sourceDirsFilePath) {
Expand Down Expand Up @@ -104,18 +104,18 @@ export class LocationManager {
sourceLineNumber: number,
sourceColumnIndex: number,
sourceDirs: string[],
stagingFolderPath: string,
stagingDir: string,
fileMappings: Array<{ src: string; dest: string }>
): Promise<{ type: 'fileMap' | 'sourceDirs' | 'sourceMap'; locations: SourceLocation[] }> {

sourceFilePath = s`${sourceFilePath}`;
sourceDirs = sourceDirs.map(x => s`${x}`);
stagingFolderPath = s`${stagingFolderPath}`;
stagingDir = s`${stagingDir}`;

//look through the sourcemaps in the staging folder for any instances of this source location
let locations = await this.sourceMapManager.getGeneratedLocations(
glob.sync('**/*.map', {
cwd: stagingFolderPath,
cwd: stagingDir,
absolute: true
}),
{
Expand All @@ -141,7 +141,7 @@ export class LocationManager {
let parentFolderPath = fileUtils.findFirstParent(sourceFilePath, sourceDirs);
if (parentFolderPath) {
let relativeFilePath = fileUtils.replaceCaseInsensitive(sourceFilePath, parentFolderPath, '');
let stagingFilePathAbsolute = path.join(stagingFolderPath, relativeFilePath);
let stagingFilePathAbsolute = path.join(stagingDir, relativeFilePath);
return {
type: 'sourceDirs',
locations: [{
Expand Down Expand Up @@ -180,7 +180,7 @@ export interface GetSourceLocationOptions {
/**
* The absolute path to the staging folder
*/
stagingFolderPath: string;
stagingDir: string;

/**
* The absolute path to the file in the staging folder
Expand Down
Loading

0 comments on commit 7e28fdb

Please sign in to comment.