Skip to content

Commit

Permalink
Better check for slow imports.
Browse files Browse the repository at this point in the history
  • Loading branch information
christopherwxyz committed Nov 30, 2022
1 parent ccb27f8 commit 1353445
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 24 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "ssync",
"version": "0.0.18",
"version": "0.0.19",
"description": "Sync a NetSuite environment with a local repository.",
"main": "./dist/app.js",
"scripts": {
Expand Down
47 changes: 24 additions & 23 deletions src/helpers/sdf.ts
Original file line number Diff line number Diff line change
Expand Up @@ -114,29 +114,30 @@ const importObjectsSlowly = async () => {
CustomObjects.forEach(async (custObject: CustomObject) => {
if (ephermeralCustomizations.includes(custObject.type)) return;
if (custObject.objects[0] === undefined) return;
if (!slowlyImportCustomizations.includes(custObject.type)) return;
console.log(`Attempting to import slow ${custObject.type} ...`)

// List all objects
custObject.objects = (await runCommand(CLICommand.ListObjects, `--type ${custObject.type}`))
.stdout
.replace(`\x1B[2K\x1B[1G`, ``)
.split('\n')
.filter(entry => entry.startsWith(custObject.type))
.map(x => x.split(":")[1]);

// Import all collected objects
const collectOutput = await runCommand(CLICommand.ImportObjects,
`--scriptid ${custObject.objects.join(" ")} ` +
`--type ${custObject.type} ` +
`--destinationfolder ${custObject.destination} ` +
`--excludefiles`
);

if (collectOutput.includes(`The following objects failed with reason "Import custom objects failed.":`)) {
custObject.error = true;
console.error(`Failed to import: ${custObject.type}`);
};
if (slowlyImportCustomizations.includes(custObject.type)) {
console.log(`Attempting to import slow ${custObject.type} ...`)

// List all objects
custObject.objects = (await runCommand(CLICommand.ListObjects, `--type ${custObject.type}`))
.stdout
.replace(`\x1B[2K\x1B[1G`, ``)
.split('\n')
.filter(entry => entry.startsWith(custObject.type))
.map(x => x.split(":")[1]);

// Import all collected objects
const collectOutput = await runCommand(CLICommand.ImportObjects,
`--scriptid ${custObject.objects.join(" ")} ` +
`--type ${custObject.type} ` +
`--destinationfolder ${custObject.destination} ` +
`--excludefiles`
);

if (collectOutput.includes(`The following objects failed with reason "Import custom objects failed.":`)) {
custObject.error = true;
console.error(`Failed to import: ${custObject.type}`);
};
}
});

CustomObjects.forEach(custObject => {
Expand Down

0 comments on commit 1353445

Please sign in to comment.