Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion redisinsight/api/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,8 @@
"scripts": {
"build:defaults:commands": "ts-node ./scripts/default-commands.ts",
"build:defaults:enablement-area": "ts-node ./scripts/default-enablement-area.ts",
"build:defaults": "yarn build:defaults:enablement-area && yarn build:defaults:commands",
"build:defaults:content": "ts-node ./scripts/default-content.ts",
"build:defaults": "yarn build:defaults:enablement-area && yarn build:defaults:commands yarn build:defaults:content",
"prebuild": "rimraf dist",
"build": "nest build",
"build:prod": "rimraf dist && nest build -p ./tsconfig.build.prod.json && cross-env NODE_ENV=production",
Expand Down
54 changes: 54 additions & 0 deletions redisinsight/api/scripts/default-content.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
import axios from 'axios';
import * as fs from 'fs-extra';
import * as path from 'path';
import { join } from 'path';
import { get } from '../src/utils/config';
import * as AdmZip from 'adm-zip';

const PATH_CONFIG = get('dir_path');
const CONTENT_CONFIG = get('content');

async function init() {
try {
await fs.remove(PATH_CONFIG.defaultContent);

await fs.ensureDir(PATH_CONFIG.defaultContent);

const { data } = await axios.get(
new URL(path.join(
CONTENT_CONFIG.updateUrl,
CONTENT_CONFIG.zip,
)).toString(),
{
responseType: 'arraybuffer',
},
);

// extract archive to default folder
const zip = new AdmZip(data);
zip.extractAllTo(PATH_CONFIG.defaultContent, true);

const { data: buildInfo } = await axios.get(
new URL(path.join(
CONTENT_CONFIG.updateUrl,
CONTENT_CONFIG.buildInfo,
)).toString(),
{
responseType: 'arraybuffer',
},
);

// save build info to default folder
await fs.writeFile(
join(PATH_CONFIG.defaultContent, CONTENT_CONFIG.buildInfo),
buildInfo,
);

process.exit(0);
} catch (e) {
console.error('Something went wrong trying to get default commands jsons', e);
process.exit(1);
}
}

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do not forget to rewrite this script using new methods that you've created for guides and tutorials

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yep. Remember it

init();