@suitegeezus/suitecloud-stacker 25.2.129 → 25.2.131
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +5 -7
- package/commands/customhook/watchss.js +1 -1
- package/commands/fileImport.d.ts +1 -1
- package/commands/fileImport.js +37 -14
- package/package.json +1 -1
- package/CONTRIBUTING.md +0 -72
- package/commands/CONTRIBUTING.md +0 -7
- package/demo.md +0 -26
package/README.md
CHANGED
|
@@ -17,8 +17,6 @@ The reason you would NOT want to use `src` is if you wanted to use the plugin to
|
|
|
17
17
|
- has extra stuff you don't want to put into the account by accident
|
|
18
18
|
- want to keep it separate
|
|
19
19
|
|
|
20
|
-
One emample in this project is that to do diffs it will automatically create a root `temp` for you.
|
|
21
|
-
|
|
22
20
|
## Attempts to facilitate any activity in an account-based project to be only for that account
|
|
23
21
|
For example, if you try to `file:upload` or `project:deploy` code it will prompt you for the account with only choices relevant to that project.
|
|
24
22
|
|
|
@@ -30,16 +28,16 @@ For example, if you try to `file:upload` or `project:deploy` code it will prompt
|
|
|
30
28
|
Should work same on Windows but i haven't tested it and i might have messed something up for windows so let me know if you have issues and you can help me fix them
|
|
31
29
|
|
|
32
30
|
1. Install SuiteCloud globally using the latest release version
|
|
31
|
+
see [`@suitegeezus/suitecloud-cli`](https://www.npmjs.com/package/@suitegeezus/suitecloud-cli)
|
|
32
|
+
read the documentation for it, to see the additional command line switches.
|
|
33
|
+
|
|
33
34
|
2. Optional: Install nodemon globally
|
|
34
35
|
```shell
|
|
35
36
|
npm install -g nodemon
|
|
36
37
|
```
|
|
37
|
-
3. Install a nice terminal that you like to use.
|
|
38
|
+
3. Optional: Install a nice terminal that you like to use.
|
|
38
39
|
- Highly recommend enhancing the mac shell with iTerm AND [Oh my Zsh!](https://ohmyz.sh/)
|
|
39
|
-
4. Optional:
|
|
40
|
-
- These are entitlements that will help you stay on the latest version of this repo and use customer repos
|
|
41
|
-
- If you can't then you can still use this for your testdrive accounts -- just ask me how
|
|
42
|
-
5Optional: Create an environment variable for SUITECLOUD_DIFF_TOOL
|
|
40
|
+
4. Optional: Create an environment variable for SUITECLOUD_DIFF_TOOL
|
|
43
41
|
```shell
|
|
44
42
|
#➜ set | grep 'DIFF'
|
|
45
43
|
export SUITECLOUD_DIFF_TOOL='/Applications/./IntelliJ\ IDEA.app/Contents/MacOS/idea'
|
|
@@ -14,7 +14,7 @@ const cp = require("node:child_process");
|
|
|
14
14
|
const assert = require("node:assert");
|
|
15
15
|
const passthroughCommand = 'custom:hook';
|
|
16
16
|
const sdfExec = process.env['SUITECLOUD_EXE'] || 'sdf';
|
|
17
|
-
const SdfCompileCommand = `${sdfExec} ${passthroughCommand} --option1 compiless`;
|
|
17
|
+
const SdfCompileCommand = `${sdfExec} ${passthroughCommand} --name compiless --option1 compiless`;
|
|
18
18
|
/**
|
|
19
19
|
* @description
|
|
20
20
|
* @example sdf custom:hook --option1 watchss --option2 ignore --multi2 module.d.ts foo.d.ts
|
package/commands/fileImport.d.ts
CHANGED
|
@@ -11,7 +11,7 @@ import { FileImportCommand, SdfCommand } from "index";
|
|
|
11
11
|
*/
|
|
12
12
|
export declare const downloadForDiff: () => SdfCommand;
|
|
13
13
|
/**
|
|
14
|
-
* @description - very similar
|
|
14
|
+
* @description - very similar to the fixFileUploadPaths except we need to compare against what is actually in netsuite
|
|
15
15
|
* Also we don't filter out any files
|
|
16
16
|
*/
|
|
17
17
|
export declare const fixFileImportPaths: () => SdfCommand;
|
package/commands/fileImport.js
CHANGED
|
@@ -9,6 +9,7 @@ const console = require("node:console");
|
|
|
9
9
|
const cp = require("node:child_process");
|
|
10
10
|
const nodePath = require("node:path");
|
|
11
11
|
const promptHelpers_1 = require("../lib/promptHelpers");
|
|
12
|
+
const pathHelpers = require("../lib/pathHelpers");
|
|
12
13
|
const tempFileHelper = require("../lib/tempFileHelper");
|
|
13
14
|
const os = require("node:os");
|
|
14
15
|
const pathHelpers_1 = require("../lib/pathHelpers");
|
|
@@ -59,7 +60,7 @@ const downloadForDiff = () => {
|
|
|
59
60
|
throw onErrorHelper.makeError(origin, new Error('Diff compare needs an array.'));
|
|
60
61
|
// single length array
|
|
61
62
|
if (options.arguments.paths.length === 0)
|
|
62
|
-
throw onErrorHelper.makeError(origin, new Error('Diff compare
|
|
63
|
+
throw onErrorHelper.makeError(origin, new Error('Diff compare needs at least 1 valid file. Perhaps your file is not in NetSuite e.g. Typescript'));
|
|
63
64
|
// fixed lists
|
|
64
65
|
const candidates = await Promise.all([...options.arguments.paths].map(async (candidate) => {
|
|
65
66
|
// normalize to file system
|
|
@@ -108,9 +109,11 @@ const downloadForDiff = () => {
|
|
|
108
109
|
cwd: os.tmpdir()
|
|
109
110
|
// spawns in a separate location but is still a child process
|
|
110
111
|
});
|
|
112
|
+
// this is allowed to fail as one environment might not have the requested file
|
|
111
113
|
if (errorCode !== 0)
|
|
112
|
-
process.
|
|
113
|
-
|
|
114
|
+
process.stdout.write((0, promptHelpers_1.goColor)('WARN', `\nimport from ${auth} failed -- probably no files matching the pattern`));
|
|
115
|
+
else
|
|
116
|
+
process.stdout.write((0, promptHelpers_1.goColor)('GOOD', `\nimport from ${auth} successful`));
|
|
114
117
|
}));
|
|
115
118
|
let diffTool = process.env.SUITECLOUD_DIFF_TOOL;
|
|
116
119
|
{
|
|
@@ -125,15 +128,34 @@ const downloadForDiff = () => {
|
|
|
125
128
|
}
|
|
126
129
|
}
|
|
127
130
|
// iterate over ALL the files to create diff commands
|
|
128
|
-
const diffCombos = candidates.map((file) => {
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
131
|
+
const diffCombos = await Promise.all(candidates.map(async (file) => {
|
|
132
|
+
const verifiedPaths = await Promise.all([...tempLocations, options.projectPath].map(async (location) => {
|
|
133
|
+
const joined = (0, pathHelpers_1.joinPaths)(location, 'FileCabinet', file);
|
|
134
|
+
// make sure the file exists
|
|
135
|
+
return (await pathHelpers.hasFile(joined))
|
|
136
|
+
? joined
|
|
137
|
+
: false;
|
|
138
|
+
}));
|
|
139
|
+
return verifiedPaths.filter(Boolean).map((f) => `"${f}"`);
|
|
140
|
+
}));
|
|
133
141
|
await diffCombos.reduce(async (linked, combo, currentIndex) => {
|
|
134
142
|
const keepGoing = await linked;
|
|
135
143
|
if (!keepGoing)
|
|
136
144
|
return keepGoing;
|
|
145
|
+
let [left, right, primary] = combo;
|
|
146
|
+
if (!primary)
|
|
147
|
+
primary = right;
|
|
148
|
+
if (!right)
|
|
149
|
+
primary = left;
|
|
150
|
+
if (combo.length <= 1) {
|
|
151
|
+
// nothing to diff
|
|
152
|
+
if (!isQuiet) {
|
|
153
|
+
await (0, promptHelpers_1.promptUser)({
|
|
154
|
+
message: `${primary} not found in any environment`,
|
|
155
|
+
});
|
|
156
|
+
}
|
|
157
|
+
return true;
|
|
158
|
+
}
|
|
137
159
|
const diffChildProc = cp.spawn(diffTool, ['diff', ...combo], {
|
|
138
160
|
detached: true, // Allows the child to run independently
|
|
139
161
|
stdio: 'inherit',
|
|
@@ -218,7 +240,7 @@ const downloadForDiff = () => {
|
|
|
218
240
|
};
|
|
219
241
|
exports.downloadForDiff = downloadForDiff;
|
|
220
242
|
/**
|
|
221
|
-
* @description - very similar
|
|
243
|
+
* @description - very similar to the fixFileUploadPaths except we need to compare against what is actually in netsuite
|
|
222
244
|
* Also we don't filter out any files
|
|
223
245
|
*/
|
|
224
246
|
const fixFileImportPaths = () => {
|
|
@@ -235,11 +257,12 @@ const fixFileImportPaths = () => {
|
|
|
235
257
|
return options;
|
|
236
258
|
const { projectPath } = options;
|
|
237
259
|
const executionPath = options.executionPath || process.cwd();
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
260
|
+
if (!isQuiet)
|
|
261
|
+
await (0, promptHelpers_1.promptUser)({
|
|
262
|
+
message: JSON.stringify({
|
|
263
|
+
executionPath, ...options, ischild: spawnSuitecloud.isChildProcess()
|
|
264
|
+
})
|
|
265
|
+
});
|
|
243
266
|
// deal with relative paths, etc 1️⃣
|
|
244
267
|
const shortenedPathOrGlobs = options.arguments.paths.map((path) => {
|
|
245
268
|
if (/^\.+[\\\/]/.test(path) && !/\bSuiteScripts\b/.test(path))
|
package/package.json
CHANGED
package/CONTRIBUTING.md
DELETED
|
@@ -1,72 +0,0 @@
|
|
|
1
|
-
## the project type is 'commonjs'
|
|
2
|
-
suitecloud-cli will only look for a config with a `.js` and never a `.cjs` extension!! 😓
|
|
3
|
-
this conflicts with how suitescript unit tests are written which is with es6 modules.
|
|
4
|
-
It is possible to use modules with flags on node so that is what we will need to do.
|
|
5
|
-
This means certain files such as suitecloud.config.js may show some resolve errors. There are some other ways to get around this b
|
|
6
|
-
|
|
7
|
-
## Your authentication is setup correctly and you are definitely pushing or pulling from the implied environment
|
|
8
|
-
Unfortunately, we are human and make mistakes. But SDF doesn't care
|
|
9
|
-
When authentication is set it will just assume this is what you want and has no safety net.
|
|
10
|
-
|
|
11
|
-
this project solves this problem by:
|
|
12
|
-
- Using the `@suitegeezus/suitecloud-cli` which has an authid argument available
|
|
13
|
-
- requiring the authid to be passed onto the command line
|
|
14
|
-
- detecting it is set in the hooks
|
|
15
|
-
- optional: erasing the project.json file before and after every execution.
|
|
16
|
-
- prompting you to enter the same authid a second time during the action
|
|
17
|
-
|
|
18
|
-
# Testing
|
|
19
|
-
|
|
20
|
-
This project lacks unit tests. It was initially difficult to figure out how to test a cli such as suitecloud more effectively in a unit test than in on the command line itself especially because it did not publish its hook behaviour. So it was often better to test by running the commands locally.
|
|
21
|
-
|
|
22
|
-
However, there should be unit tests and the stackable system makes it easy to do so.
|
|
23
|
-
|
|
24
|
-
Running the compiler with `map` files and in watch mode helps a lot.
|
|
25
|
-
|
|
26
|
-
# Writing Code
|
|
27
|
-
All code needs to be in Typescript
|
|
28
|
-
|
|
29
|
-
Anything that is a stackable handler should be for a specific command and be in the `commands/` directory.
|
|
30
|
-
|
|
31
|
-
e.g. something for `file:import` goes in `commands/fileImport.ts`
|
|
32
|
-
|
|
33
|
-
Each handler should be function that return `SdfCommand` type. Which has this shape:
|
|
34
|
-
```ts
|
|
35
|
-
interface SdfCommand{
|
|
36
|
-
beforeExecuting?: <O>(options:O)=>Promise<O>;
|
|
37
|
-
onCompleted?: <O>(options:O)=>Promise<O>;
|
|
38
|
-
onError?: <S>(err:S)=>Promise<S>;
|
|
39
|
-
projectFolder?: string;
|
|
40
|
-
/** @description - non native but added for detection */
|
|
41
|
-
stacked: true;
|
|
42
|
-
isStackable: true;
|
|
43
|
-
_origin: string;
|
|
44
|
-
}
|
|
45
|
-
```
|
|
46
|
-
|
|
47
|
-
## Throwing Errors
|
|
48
|
-
- SDF only passes strings to `onError`
|
|
49
|
-
- SDF always prints the message
|
|
50
|
-
|
|
51
|
-
- so ....
|
|
52
|
-
You should call `makeError` when throwing errors. This will throw a serialized string but log the stack first.
|
|
53
|
-
```ts
|
|
54
|
-
throw onErrorHelper.makeError(origin, new Error('whatever'));
|
|
55
|
-
```
|
|
56
|
-
|
|
57
|
-
Your `onError` method should be the returnType of `detectOriginAndReturn`
|
|
58
|
-
|
|
59
|
-
```ts
|
|
60
|
-
onError : async (error:string)=> onErrorHelper.detectOriginAndReturn(
|
|
61
|
-
origin, // : string,
|
|
62
|
-
error, // string-- the non-serialized message
|
|
63
|
-
(e: string /* this will only be the message portion */)=>{
|
|
64
|
-
// you can do things in here like
|
|
65
|
-
// - print a friendlier message when it's not a catastropich error
|
|
66
|
-
// - print a usage
|
|
67
|
-
}
|
|
68
|
-
);
|
|
69
|
-
```
|
|
70
|
-
If you need the results of an SDF command that is supported and you'll see examples
|
|
71
|
-
|
|
72
|
-
Anything that is re-usable should be somewhere in `sdf/lib`.
|
package/commands/CONTRIBUTING.md
DELETED
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
In this folder each library should export handlers related to an SDF command.
|
|
2
|
-
|
|
3
|
-
e.g. fileImport.ts serves `file:import` related commands.
|
|
4
|
-
|
|
5
|
-
These handler should return sdf-expected methods and each method should be stackable / chainable. See [sdf/safeCommands/stack](../safeCommands.ts);
|
|
6
|
-
|
|
7
|
-
Tests would be great. Use proxies to glean the arguments that SDF passed in and use those as your mock options.
|
package/demo.md
DELETED
|
@@ -1,26 +0,0 @@
|
|
|
1
|
-
# Overview / Features
|
|
2
|
-
|
|
3
|
-
* build a UserEvent that will help with adhoc debugging
|
|
4
|
-
* 3 different UEs
|
|
5
|
-
* separation of beforeLoad, beforeSubmit, afterSubmit
|
|
6
|
-
* deployable to any record
|
|
7
|
-
* easier ordering of rank
|
|
8
|
-
* each can launch other UEs
|
|
9
|
-
|
|
10
|
-
# Requirements
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
# Objects & Scripts
|
|
14
|
-
|
|
15
|
-
## Objects
|
|
16
|
-
1. UserEvent record for each entry point method
|
|
17
|
-
2. script parameter that will accept a scriptid / filepath (string)
|
|
18
|
-
|
|
19
|
-
## Scripts
|
|
20
|
-
1. Script for beforeLoad
|
|
21
|
-
2. Script for beforeSubmit
|
|
22
|
-
3. Script for afterSubmit
|
|
23
|
-
4. A generic function to proxy an unknown script
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|