Socket
Socket
Sign inDemoInstall

intern-dev

Package Overview
Dependencies
148
Maintainers
1
Versions
17
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

Comparing version 0.2.10 to 0.3.0

7

common.d.ts

@@ -0,2 +1,4 @@

/// <reference types="node" />
/// <reference types="glob" />
import { ChildProcess } from 'child_process';
import { ExecOptions, ExecOutputReturnValue } from 'shelljs';

@@ -17,3 +19,3 @@ import { IOptions } from 'glob';

}
export declare function compile(tsconfig: string): ExecReturnValue;
export declare function compile(tsconfig: string, watch?: boolean): ExecOutputReturnValue | ChildProcess;
export declare function copyAll(patterns: (string | FilePattern)[], outDir: string): void;

@@ -26,4 +28,7 @@ export declare function exec(command: string, options?: ExecOptions): ExecReturnValue;

export declare function lint(tsconfigFile: string): ExecReturnValue;
export declare function log(...args: any[]): void;
export declare function parseJson(text: string): any;
export declare function readJsonFile(filename: string): any;
export declare function stylus(files: string[], watch?: boolean): ExecReturnValue | ChildProcess;
export declare function webpack(config: string, watch?: boolean): ExecReturnValue | ChildProcess;
export declare class ExecError extends Error {

@@ -30,0 +35,0 @@ code: number;

@@ -18,3 +18,3 @@ "use strict";

var packageJson = readJsonFile('package.json');
var internDev = packageJson.internDev;
var internDev = packageJson.internDev || {};
exports.internDev = internDev;

@@ -25,4 +25,11 @@ var tsconfig = readJsonFile('tsconfig.json');

exports.buildDir = buildDir;
function compile(tsconfig) {
return exec("tsc -p \"" + tsconfig + "\"");
function compile(tsconfig, watch) {
if (watch === void 0) { watch = false; }
var cmd = "tsc -p \"" + tsconfig + "\"";
var opts = {};
if (watch) {
cmd += ' --watch';
opts.async = true;
}
return exec(cmd, opts);
}

@@ -48,3 +55,3 @@ exports.compile = compile;

}
shelljs_1.echo("## Copying " + filename + " to " + dst);
log("Copying " + filename + " to " + dst);
shelljs_1.cp(path_1.join(options.cwd, filename), dst);

@@ -106,2 +113,10 @@ });

exports.lint = lint;
function log() {
var args = [];
for (var _i = 0; _i < arguments.length; _i++) {
args[_i] = arguments[_i];
}
shelljs_1.echo.apply(void 0, [new Date().toLocaleTimeString() + " -"].concat(args));
}
exports.log = log;
function parseJson(text) {

@@ -116,2 +131,24 @@ var textToParse = removeComments(text);

exports.readJsonFile = readJsonFile;
function stylus(files, watch) {
if (watch === void 0) { watch = false; }
var cmd = "stylus '" + files.join('\',\'') + "'";
var opts = {};
if (watch) {
cmd += ' --watch';
opts.async = true;
}
return exec(cmd, opts);
}
exports.stylus = stylus;
function webpack(config, watch) {
if (watch === void 0) { watch = false; }
var cmd = "webpack --config \"" + config + "\"";
var opts = {};
if (watch) {
cmd += ' --watch';
opts.async = true;
}
return exec(cmd, opts);
}
exports.webpack = webpack;
var ExecError = (function (_super) {

@@ -118,0 +155,0 @@ __extends(ExecError, _super);

#!/usr/bin/env node
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
var shelljs_1 = require("shelljs");
var child_process_1 = require("child_process");
var chokidar_1 = require("chokidar");
var path_1 = require("path");
var chalk_1 = require("chalk");
var shelljs_1 = require("shelljs");
var fs_1 = require("fs");
var common_1 = require("./common");
var args = process.argv.slice(2);
var watchMode = args[0] === 'watch';
common_1.getConfigs().forEach(function (tsconfig) {
try {
shelljs_1.echo("## Linting " + path_1.dirname(tsconfig));
common_1.lint(tsconfig);
shelljs_1.echo("## Compiling " + path_1.dirname(tsconfig));
common_1.compile(tsconfig);
common_1.log("Linting " + path_1.dirname(tsconfig));
common_1.lint(tsconfig);
common_1.log("Compiling " + path_1.dirname(tsconfig));
var tag = "tsc:" + path_1.dirname(tsconfig);
if (watchMode) {
var proc = child_process_1.spawn('tsc', ['-p', tsconfig, '--watch']);
watchProcess(tag, proc, /\berror TS\d+:/);
}
catch (error) {
if (error.name === 'ExecError') {
shelljs_1.echo(chalk_1.red(error.stdout));
process.exit(error.code);
}
else {
throw error;
}
else {
var proc = child_process_1.spawnSync('tsc', ['-p', tsconfig]);
logProcess(tag, proc, /\berror TS\d+:/);
}
});
if (common_1.tsconfig.compilerOptions.inlineSources) {
shelljs_1.echo('## Fixing source map paths');
common_1.fixSourceMaps();
}
common_1.copyAll([
var buildDst = path_1.join(common_1.buildDir, 'src');
var resources = common_1.internDev.resources || {};
resources[buildDst] = (resources[buildDst] || []).concat([
'package.json',
'README*',
'LICENSE*'
], path_1.join(common_1.buildDir, 'src'));
if (common_1.internDev && common_1.internDev.resources) {
var resources_1 = common_1.internDev.resources;
Object.keys(resources_1).forEach(function (dest) {
common_1.copyAll(resources_1[dest], dest);
]);
Object.keys(resources).forEach(function (dest) {
common_1.copyAll(resources[dest], dest);
if (watchMode) {
createFileWatcher(resources[dest], dest);
}
});
var webpackConfig = common_1.internDev.webpack || 'webpack.config.js';
if (fs_1.existsSync(webpackConfig)) {
if (watchMode) {
var proc = child_process_1.spawn('webpack', ['--config', webpackConfig, '--watch']);
watchProcess('webpack', proc, /^ERROR\b/);
}
else {
var proc = child_process_1.spawnSync('webpack', ['--config', webpackConfig]);
logProcess('webpack', proc, /^ERROR\b/);
}
}
if (common_1.internDev.stylus) {
if (watchMode) {
var proc = child_process_1.spawn('stylus', common_1.internDev.stylus.concat('--watch'));
watchProcess('stylus', proc);
}
else {
var proc = child_process_1.spawnSync('stylus', common_1.internDev.stylus);
logProcess('stylus', proc);
}
}
common_1.log('Done building');
function createFileWatcher(patterns, dstDir) {
if (!Array.isArray(dstDir)) {
dstDir = [dstDir];
}
dstDir.forEach(function (dir) { return shelljs_1.mkdir('-p', path_1.dirname(dir)); });
var watcher = chokidar_1.watch(patterns)
.on('ready', function () {
common_1.log("Watching files for " + patterns[0] + " => " + dstDir);
watcher.on('add', function (file) { return copy(file, dstDir); });
watcher.on('change', function (file) { return copy(file, dstDir); });
watcher.on('unlink', function (file) { return remove(file, dstDir); });
})
.on('error', function (error) {
common_1.log(chalk_1.red("!!"), 'Watcher error:', error);
});
return watcher;
}
shelljs_1.echo('## Done building');
function copy(file, dstDir) {
if (!Array.isArray(dstDir)) {
dstDir = [dstDir];
}
dstDir.forEach(function (dir) {
shelljs_1.cp(file, dir);
common_1.log("Copied " + file + " -> " + dir);
});
}
function logProcess(name, proc, errorTest) {
if (proc.status) {
logProcessOutput(name, proc.stdout || proc.stderr, /.*/);
common_1.log(chalk_1.red("Error running " + name + ", exiting..."));
process.exit(1);
}
else {
logProcessOutput(name, proc.stdout, errorTest);
}
}
function logProcessOutput(name, text, errorTest) {
if (!text) {
return;
}
if (typeof text !== 'string') {
text = text.toString('utf8');
}
var lines = text.split('\n')
.filter(function (line) { return !(/^\s*$/.test(line)); })
.filter(function (line) { return !(/^Child$/.test(line)); })
.map(function (line) { return line.replace(/^\s+/, '').replace(/\s+$/, ''); })
.map(function (line) { return /^\d\d:\d\d:\d\d \w\w -/.test(line) ? line.slice(line.indexOf('-') + 2) : line; });
if (errorTest) {
lines = lines.map(function (line) { return errorTest.test(line) ? chalk_1.red(line) : line; });
}
lines.forEach(function (line) { common_1.log("[" + name + "] " + line); });
}
function remove(file, dstDir) {
if (!Array.isArray(dstDir)) {
dstDir = [dstDir];
}
dstDir.forEach(function (dir) {
try {
var path = path_1.join(dir, file);
shelljs_1.rm(path);
common_1.log("Removed " + path);
}
catch (error) {
}
});
}
function watchProcess(name, proc, errorTest) {
proc.stdout.on('data', function (data) {
logProcessOutput(name, data.toString('utf8'), errorTest);
});
proc.stderr.on('data', function (data) {
logProcessOutput(name, data.toString('utf8'), errorTest);
});
proc.on('error', function () {
process.exit(1);
});
}

4

intern-dev-clean.js

@@ -12,6 +12,6 @@ #!/usr/bin/env node

outDir = path_1.relative(process.cwd(), path_1.join(path_1.dirname(configFile), outDir));
shelljs_1.echo("## Removing " + outDir);
common_1.log("Removing " + outDir);
shelljs_1.rm('-rf', outDir);
}
});
shelljs_1.echo('## Done cleaning');
common_1.log('Done cleaning');
{
"name": "intern-dev",
"version": "0.2.10",
"version": "0.3.0",
"description": "Development support scripts for Intern projects.",

@@ -25,9 +25,8 @@ "repository": {

"devDependencies": {
"@types/browserify": "~12.0.31",
"@types/chalk": "~0.4.31",
"@types/chokidar": "~1.6.0",
"@types/glob": "~5.0.30",
"@types/node": "~7.0.23",
"@types/semver": "~5.3.31",
"@types/shelljs": "~0.7.1",
"@types/node": "~7.0.23",
"ts-node": "~3.0.4"

@@ -34,0 +33,0 @@ },

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc