Skip to content

Commit

Permalink
build: move scripts to TS
Browse files Browse the repository at this point in the history
  • Loading branch information
dm-p committed Dec 3, 2023
1 parent 0dab797 commit ce0b9c3
Show file tree
Hide file tree
Showing 5 changed files with 40 additions and 21 deletions.
20 changes: 12 additions & 8 deletions bin/package-custom.js → bin/package-custom.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
const fs = require('fs');
const exec = require('child_process').exec;
const git = require('git-last-commit');
const _ = require('lodash');
const parseArgs = require('minimist');
const { exit } = require('process');
const config = require('./package-custom-config.json');
import fs from 'fs';
import { exec } from 'child_process';
import git from 'git-last-commit';
import _ from 'lodash';
import parseArgs from 'minimist';
import process, { exit } from 'process';
import config from './package-custom-config.json';

const pbivizFile = 'pbiviz.json';
const pbivizFilePath = '.';
const configFile = 'deneb-config.json';
Expand All @@ -15,7 +16,10 @@ const pbivizOriginal = require(`../${pbivizFile}`);
const configOriginal = require(`../config/${configFile}`);
const capabilitiesOriginal = require(`../${capabilitiesFile}`);

const runNpmScript = (script, callback) => {
const runNpmScript = (
script: string,
callback: (err: Error | null) => void | null
) => {
// keep track of whether callback has been invoked to prevent multiple invocations
var invoked = false;
var process = exec(script);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,21 +1,15 @@
const { exit } = require('process');
const config = require('../config/deneb-config.json');
import { exit } from 'process';
import * as config from '../config/deneb-config.json';

console.log('Checking visual configuration is correct...\n');
const errors = [];
const errors: string[] = [];

// Developer mode: Should not be set in committed code
if (config.features.developerMode) {
errors.push(
'❌ features.developerMode flag is true; this should be false.'
);
}
// React logging: Should not be set in committed code
if (config.features.enableReactLogging) {
errors.push(
'❌ features.enableReactLogging flag is true; this should be false.'
);
}
// Visual update history overlay: Should not be set in committed code
if (config.features.visualUpdateHistoryOverlay) {
errors.push(
Expand Down
13 changes: 13 additions & 0 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

9 changes: 5 additions & 4 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,14 +7,14 @@
"install-cert": "pbiviz install-cert",
"start": "npm run template-schemagen && pbiviz start --all-locales",
"package": "npm run validate-config-for-commit && npm run template-schemagen && pbiviz package --all-locales",
"package-standalone": "npm run template-schemagen && node bin/package-custom --mode standalone",
"package-alpha": "npm run template-schemagen && node bin/package-custom --mode alpha",
"package-beta": "npm run template-schemagen && node bin/package-custom --mode beta",
"package-standalone": "npm run template-schemagen && ts-node -P tsconfig.build-scripts.json bin/package-custom --mode standalone",
"package-alpha": "npm run template-schemagen && ts-node -P tsconfig.build-scripts.json bin/package-custom --mode alpha",
"package-beta": "npm run template-schemagen && ts-node -P tsconfig.build-scripts.json bin/package-custom --mode beta",
"eslint": "npx eslint . --ext .js,.jsx,.ts,.tsx --max-warnings 0",
"prettier-check": "prettier --config .prettierrc {src,spec,style}/**/{*.ts*,*.css,*.less} --check",
"prettier-format": "prettier --config .prettierrc {src,spec,style}/**/{*.ts*,*.css,*.less} --write",
"template-schemagen": "typescript-json-schema ./src/features/template/schema.ts IDenebTemplateMetadata -o ./schema/deneb-template-usermeta-v1.json --required --topRef",
"validate-config-for-commit": "node bin/validate-config-for-commit"
"validate-config-for-commit": "ts-node -P tsconfig.build-scripts.json bin/validate-config-for-commit"
},
"devDependencies": {
"@babel/core": "^7.15.0",
Expand All @@ -29,6 +29,7 @@
"@types/jsoneditor": "^8.6.0",
"@types/jsum": "^0.1.0",
"@types/lodash": "^4.14.168",
"@types/minimist": "^1.2.5",
"@types/node": "^16.4.12",
"@types/react": "^17.0.0",
"@types/react-dom": "^17.0.0",
Expand Down
7 changes: 7 additions & 0 deletions tsconfig.build-scripts.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"extends": "./tsconfig.json",
"compilerOptions": {
"module": "commonjs",
"types": ["node"]
}
}

0 comments on commit ce0b9c3

Please sign in to comment.