@jupiterone/cli 8.3.1 → 8.4.2
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/__mocks__/ora.ts +1 -1
- package/dist/src/commands/j1Export.js +4 -4
- package/dist/src/commands/j1Export.js.map +1 -1
- package/dist/src/commands/j1Import.js +4 -4
- package/dist/src/commands/j1Import.js.map +1 -1
- package/dist/src/export/bulkDownloadToJson.js +6 -6
- package/dist/src/export/bulkDownloadToJson.js.map +1 -1
- package/dist/src/export/exportAssets.js +3 -3
- package/dist/src/export/exportAssets.js.map +1 -1
- package/dist/src/export/exportAssetsToJson.js +3 -3
- package/dist/src/export/exportAssetsToJson.js.map +1 -1
- package/dist/src/export/exportJsonAssetsToCsv.js +5 -5
- package/dist/src/export/exportJsonAssetsToCsv.js.map +1 -1
- package/dist/src/export/groupJsonAssetsByType.d.ts +1 -1
- package/dist/src/export/groupJsonAssetsByType.js +5 -6
- package/dist/src/export/groupJsonAssetsByType.js.map +1 -1
- package/dist/src/export/util.js.map +1 -1
- package/dist/src/export/writeAssetsToCsv.d.ts +1 -1
- package/dist/src/export/writeAssetsToCsv.js +6 -6
- package/dist/src/export/writeAssetsToCsv.js.map +1 -1
- package/dist/src/fileSystem.d.ts +1 -1
- package/dist/src/fileSystem.js +2 -2
- package/dist/src/fileSystem.js.map +1 -1
- package/dist/src/import/importAssets.js +1 -1
- package/dist/src/import/importAssets.js.map +1 -1
- package/dist/src/import/importAssetsFromCsv.js +9 -9
- package/dist/src/import/importAssetsFromCsv.js.map +1 -1
- package/dist/src/index.js +1 -3
- package/dist/src/index.js.map +1 -1
- package/dist/src/pause.js +3 -1
- package/dist/src/pause.js.map +1 -1
- package/dist/tsconfig.dist.tsbuildinfo +1 -7051
- package/jest.config.js +1 -1
- package/package.json +4 -4
- package/src/__tests__/cli-import.test.ts +6 -9
- package/src/__tests__/utils/fetchAssetsContents.ts +3 -3
- package/src/__tests__/utils/index.ts +1 -1
- package/src/export/__tests__/exportAssetsToJson.test.ts +56 -41
- package/src/export/__tests__/exportJsonAssetsToCsv.test.ts +117 -71
- package/src/export/__tests__/groupJsonAssetsByType.test.ts +6 -4
- package/src/export/__tests__/utils/createEntity.ts +13 -5
- package/src/export/__tests__/utils/createRelationship.ts +1 -1
- package/src/export/__tests__/utils/parseCsvToJson.ts +2 -2
- package/src/export/__tests__/utils/parseToCsv.ts +2 -3
- package/src/export/__tests__/writeAssetsToCsv.test.ts +6 -8
- package/src/export/exportAssets.ts +6 -2
- package/src/export/groupJsonAssetsByType.ts +12 -9
- package/src/export/util.ts +2 -2
- package/src/export/writeAssetsToCsv.ts +21 -12
- package/src/fileSystem.ts +6 -3
- package/src/index.ts +1 -3
- package/src/pause.ts +3 -1
- package/tsconfig.dist.json +1 -3
- package/tsconfig.json +2 -4
|
@@ -3,7 +3,11 @@ import jsonexport from 'jsonexport';
|
|
|
3
3
|
import { v4 as uuid } from 'uuid';
|
|
4
4
|
import _ from 'lodash';
|
|
5
5
|
|
|
6
|
-
import {
|
|
6
|
+
import {
|
|
7
|
+
ensureDirectoryExists,
|
|
8
|
+
readJsonFromPath,
|
|
9
|
+
writeFileToPath,
|
|
10
|
+
} from '../fileSystem';
|
|
7
11
|
|
|
8
12
|
type GroupedAssets = { [type: string]: string[] };
|
|
9
13
|
|
|
@@ -12,17 +16,22 @@ interface WriteAssetsToCsvParams {
|
|
|
12
16
|
groupedAssetFiles: GroupedAssets;
|
|
13
17
|
}
|
|
14
18
|
|
|
15
|
-
export async function writeAssetsToCsv({
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
+
export async function writeAssetsToCsv({
|
|
20
|
+
groupedAssetFiles,
|
|
21
|
+
directory,
|
|
22
|
+
}: WriteAssetsToCsvParams) {
|
|
23
|
+
await Promise.all(
|
|
24
|
+
Object.keys(groupedAssetFiles).map(async (type) => {
|
|
25
|
+
for (const assetFile of groupedAssetFiles[type]) {
|
|
26
|
+
const assetPath = path.join(directory, type, `${uuid()}.csv`);
|
|
19
27
|
|
|
20
|
-
|
|
28
|
+
await ensureDirectoryExists(assetPath);
|
|
21
29
|
|
|
22
|
-
|
|
23
|
-
|
|
30
|
+
const assets = await readJsonFromPath(assetFile);
|
|
31
|
+
const csv = await jsonexport(assets);
|
|
24
32
|
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
33
|
+
await writeFileToPath({ filePath: assetPath, content: csv });
|
|
34
|
+
}
|
|
35
|
+
}),
|
|
36
|
+
);
|
|
37
|
+
}
|
package/src/fileSystem.ts
CHANGED
|
@@ -11,9 +11,12 @@ export async function ensureDirectoryExists(pathToWrite: string) {
|
|
|
11
11
|
await fs.mkdir(directoryPath, { recursive: true });
|
|
12
12
|
}
|
|
13
13
|
|
|
14
|
-
export async function writeFileToPath({
|
|
15
|
-
filePath
|
|
16
|
-
content
|
|
14
|
+
export async function writeFileToPath({
|
|
15
|
+
filePath,
|
|
16
|
+
content,
|
|
17
|
+
}: {
|
|
18
|
+
filePath: string;
|
|
19
|
+
content: string;
|
|
17
20
|
}) {
|
|
18
21
|
await ensureDirectoryExists(filePath);
|
|
19
22
|
await fs.writeFile(filePath, content, 'utf8');
|
package/src/index.ts
CHANGED
|
@@ -3,7 +3,5 @@ import { createCommand } from 'commander';
|
|
|
3
3
|
import { j1Export, j1Import } from './commands';
|
|
4
4
|
|
|
5
5
|
export function createCli() {
|
|
6
|
-
return createCommand()
|
|
7
|
-
.addCommand(j1Import())
|
|
8
|
-
.addCommand(j1Export())
|
|
6
|
+
return createCommand().addCommand(j1Import()).addCommand(j1Export());
|
|
9
7
|
}
|
package/src/pause.ts
CHANGED
package/tsconfig.dist.json
CHANGED
package/tsconfig.json
CHANGED