now modularized, implements #11
This commit is contained in:
4
dist/mod00/index.d.ts
vendored
Normal file
4
dist/mod00/index.d.ts
vendored
Normal file
@ -0,0 +1,4 @@
|
||||
/// <reference types="q" />
|
||||
import * as q from 'q';
|
||||
import { INpmtsConfig } from '../npmts.config';
|
||||
export declare let run: (configArg: INpmtsConfig) => q.Promise<INpmtsConfig>;
|
22
dist/mod00/index.js
vendored
Normal file
22
dist/mod00/index.js
vendored
Normal file
@ -0,0 +1,22 @@
|
||||
"use strict";
|
||||
/* ------------------------------------------
|
||||
* This module compiles TypeScript files
|
||||
* -------------------------------------------- */
|
||||
const q = require("q");
|
||||
const npmts_log_1 = require("../npmts.log");
|
||||
const NpmtsAssets = require("./mod00.assets");
|
||||
const NpmtsCheck = require("./mod00.check");
|
||||
const NpmtsClean = require("./mod00.clean");
|
||||
const NpmtsCompile = require("./mod00.compile");
|
||||
exports.run = function (configArg) {
|
||||
let done = q.defer();
|
||||
npmts_log_1.npmtsOra.text('starting TypeScript Compilation');
|
||||
NpmtsClean.run(configArg)
|
||||
.then(NpmtsCheck.run)
|
||||
.then(NpmtsCompile.run)
|
||||
.then(NpmtsAssets.run)
|
||||
.then(function () {
|
||||
done.resolve(configArg);
|
||||
});
|
||||
return done.promise;
|
||||
};
|
3
dist/mod00/mod00.assets.d.ts
vendored
Normal file
3
dist/mod00/mod00.assets.d.ts
vendored
Normal file
@ -0,0 +1,3 @@
|
||||
/// <reference types="q" />
|
||||
import * as q from 'q';
|
||||
export declare var run: (configArg: any) => q.Promise<{}>;
|
24
dist/mod00/mod00.assets.js
vendored
Normal file
24
dist/mod00/mod00.assets.js
vendored
Normal file
@ -0,0 +1,24 @@
|
||||
"use strict";
|
||||
const q = require("q");
|
||||
const paths = require("../npmts.paths");
|
||||
const npmts_log_1 = require("../npmts.log");
|
||||
const plugins = require("./mod00.plugins");
|
||||
const mod00_check_1 = require("../mod00/mod00.check");
|
||||
exports.run = function (configArg) {
|
||||
let done = q.defer();
|
||||
let config = configArg;
|
||||
npmts_log_1.npmtsOra.text('now looking at ' + 'required assets'.yellow);
|
||||
if (config.cli === true) {
|
||||
let mainJsPath = mod00_check_1.projectInfo.packageJson.main;
|
||||
let cliJsString = plugins.smartfile.fs.toStringSync(plugins.path.join(paths.npmtsAssetsDir, 'cli.js'));
|
||||
cliJsString = cliJsString.replace('{{pathToIndex}}', mainJsPath);
|
||||
plugins.smartfile.memory.toFsSync(cliJsString, plugins.path.join(paths.distDir, 'cli.js'));
|
||||
plugins.beautylog.ok('installed CLI assets!');
|
||||
done.resolve(config);
|
||||
}
|
||||
else {
|
||||
plugins.beautylog.ok('No additional assets required!');
|
||||
done.resolve(config);
|
||||
}
|
||||
return done.promise;
|
||||
};
|
5
dist/mod00/mod00.check.d.ts
vendored
Normal file
5
dist/mod00/mod00.check.d.ts
vendored
Normal file
@ -0,0 +1,5 @@
|
||||
/// <reference types="q" />
|
||||
import * as q from 'q';
|
||||
import { ProjectinfoNpm } from 'projectinfo';
|
||||
export declare let projectInfo: ProjectinfoNpm;
|
||||
export declare let run: (configArg: any) => q.Promise<{}>;
|
120
dist/mod00/mod00.check.js
vendored
Normal file
120
dist/mod00/mod00.check.js
vendored
Normal file
@ -0,0 +1,120 @@
|
||||
"use strict";
|
||||
const q = require("q");
|
||||
const projectinfo_1 = require("projectinfo");
|
||||
const paths = require("../npmts.paths");
|
||||
const npmts_log_1 = require("../npmts.log");
|
||||
const plugins = require("./mod00.plugins");
|
||||
let checkProjectTypings = (configArg) => {
|
||||
let done = q.defer();
|
||||
npmts_log_1.npmtsOra.text('Check Module: Check Project Typings...');
|
||||
exports.projectInfo = new projectinfo_1.ProjectinfoNpm(paths.cwd);
|
||||
if (typeof exports.projectInfo.packageJson.typings === 'undefined') {
|
||||
plugins.beautylog.error(`please add typings field to package.json`);
|
||||
process.exit(1);
|
||||
}
|
||||
;
|
||||
done.resolve(configArg);
|
||||
return done.promise;
|
||||
};
|
||||
const depcheckOptions = {
|
||||
ignoreBinPackage: false,
|
||||
parsers: {
|
||||
'*.ts': plugins.depcheck.parser.typescript
|
||||
},
|
||||
detectors: [
|
||||
plugins.depcheck.detector.requireCallExpression,
|
||||
plugins.depcheck.detector.importDeclaration
|
||||
],
|
||||
specials: [
|
||||
plugins.depcheck.special.eslint,
|
||||
plugins.depcheck.special.webpack
|
||||
]
|
||||
};
|
||||
let checkDependencies = (configArg) => {
|
||||
let done = q.defer();
|
||||
npmts_log_1.npmtsOra.text('Check Module: Check Dependencies...');
|
||||
let depcheckOptionsMerged = plugins.lodash.merge(depcheckOptions, {
|
||||
ignoreDirs: [
|
||||
'test',
|
||||
'dist',
|
||||
'bower_components'
|
||||
],
|
||||
ignoreMatches: [
|
||||
'@types/*',
|
||||
'babel-preset-*'
|
||||
]
|
||||
});
|
||||
plugins.depcheck(paths.cwd, depcheckOptionsMerged, (unused) => {
|
||||
for (let item of unused.dependencies) {
|
||||
plugins.beautylog.warn(`Watch out: unused dependency "${item}"`);
|
||||
}
|
||||
for (let item in unused.missing) {
|
||||
plugins.beautylog.error(`unused devDependency "${item}"`);
|
||||
}
|
||||
if (unused.missing.length > 0) {
|
||||
plugins.beautylog.info('exiting due to missing dependencies in package.json');
|
||||
process.exit(1);
|
||||
}
|
||||
for (let item in unused.invalidFiles) {
|
||||
plugins.beautylog.warn(`Watch out: could not parse file ${item.red}`);
|
||||
}
|
||||
;
|
||||
for (let item in unused.invalidDirs) {
|
||||
plugins.beautylog.warn(`Watch out: could not parse directory ${item.red}`);
|
||||
}
|
||||
done.resolve(configArg);
|
||||
});
|
||||
return done.promise;
|
||||
};
|
||||
let checkDevDependencies = (configArg) => {
|
||||
let done = q.defer();
|
||||
npmts_log_1.npmtsOra.text('Check Module: Check devDependencies...');
|
||||
let depcheckOptionsMerged = plugins.lodash.merge(depcheckOptions, {
|
||||
ignoreDirs: [
|
||||
'ts',
|
||||
'dist',
|
||||
'bower_components'
|
||||
],
|
||||
ignoreMatches: [
|
||||
'@types/*',
|
||||
'babel-preset-*'
|
||||
]
|
||||
});
|
||||
plugins.depcheck(paths.cwd, depcheckOptionsMerged, (unused) => {
|
||||
for (let item of unused.devDependencies) {
|
||||
plugins.beautylog.log(`unused devDependency ${item.red}`);
|
||||
}
|
||||
for (let item in unused.missing) {
|
||||
plugins.beautylog.error(`unused devDependency ${item.red}`);
|
||||
}
|
||||
if (unused.missing.length > 0) {
|
||||
plugins.beautylog.info('exiting due to missing dependencies in package.json');
|
||||
process.exit(1);
|
||||
}
|
||||
for (let item in unused.invalidFiles) {
|
||||
plugins.beautylog.warn(`Watch out: could not parse file ${item.red}`);
|
||||
}
|
||||
for (let item in unused.invalidDirs) {
|
||||
plugins.beautylog.warn(`Watch out: could not parse directory ${item.red}`);
|
||||
}
|
||||
done.resolve(configArg);
|
||||
});
|
||||
return done.promise;
|
||||
};
|
||||
let checkNodeVersion = (configArg) => {
|
||||
let done = q.defer();
|
||||
npmts_log_1.npmtsOra.text('checking node version');
|
||||
done.resolve(configArg);
|
||||
return done.promise;
|
||||
};
|
||||
exports.run = (configArg) => {
|
||||
let done = q.defer();
|
||||
npmts_log_1.npmtsOra.text('Check Module: ...');
|
||||
checkProjectTypings(configArg)
|
||||
.then(checkDependencies)
|
||||
.then(checkDevDependencies)
|
||||
.then(checkNodeVersion)
|
||||
.then(done.resolve)
|
||||
.catch((err) => { console.log(err); });
|
||||
return done.promise;
|
||||
};
|
3
dist/mod00/mod00.clean.d.ts
vendored
Normal file
3
dist/mod00/mod00.clean.d.ts
vendored
Normal file
@ -0,0 +1,3 @@
|
||||
/// <reference types="q" />
|
||||
import * as q from 'q';
|
||||
export declare let run: (configArg: any) => q.Promise<{}>;
|
42
dist/mod00/mod00.clean.js
vendored
Normal file
42
dist/mod00/mod00.clean.js
vendored
Normal file
@ -0,0 +1,42 @@
|
||||
"use strict";
|
||||
const q = require("q");
|
||||
const paths = require("../npmts.paths");
|
||||
const npmts_log_1 = require("../npmts.log");
|
||||
const plugins = require("./mod00.plugins");
|
||||
/**
|
||||
* removes the dist directory which will be entirely rebuild
|
||||
*/
|
||||
let removeDist = function () {
|
||||
npmts_log_1.npmtsOra.text('cleaning dist folder');
|
||||
return plugins.smartfile.fs.remove(paths.distDir);
|
||||
};
|
||||
/**
|
||||
* remove .d.ts files from testDirctory
|
||||
*/
|
||||
let removeTestDeclarations = function () {
|
||||
let done = q.defer();
|
||||
plugins.smartfile.fs.listFileTree('./test/', '**/*.d.ts').then(fileArray => {
|
||||
let fileArrayToRemove = plugins.smartpath.transform.toAbsolute(fileArray, process.cwd() + '//test/');
|
||||
plugins.smartfile.fs.removeManySync(fileArrayToRemove);
|
||||
done.resolve();
|
||||
});
|
||||
};
|
||||
/**
|
||||
* remove old pages
|
||||
*/
|
||||
let removePages = function () {
|
||||
npmts_log_1.npmtsOra.text('cleaning pages folder');
|
||||
return plugins.smartfile.fs.remove(paths.pagesDir);
|
||||
};
|
||||
exports.run = function (configArg) {
|
||||
npmts_log_1.npmtsOra.text('cleaning up from previous builds...');
|
||||
let done = q.defer();
|
||||
removeDist()
|
||||
.then(removeTestDeclarations)
|
||||
.then(removePages)
|
||||
.then(function () {
|
||||
plugins.beautylog.ok('Cleaned up from previous builds!');
|
||||
done.resolve(configArg);
|
||||
});
|
||||
return done.promise;
|
||||
};
|
3
dist/mod00/mod00.compile.d.ts
vendored
Normal file
3
dist/mod00/mod00.compile.d.ts
vendored
Normal file
@ -0,0 +1,3 @@
|
||||
/// <reference types="q" />
|
||||
import * as q from 'q';
|
||||
export declare let run: (configArg: any) => q.Promise<{}>;
|
21
dist/mod00/mod00.compile.js
vendored
Normal file
21
dist/mod00/mod00.compile.js
vendored
Normal file
@ -0,0 +1,21 @@
|
||||
"use strict";
|
||||
const q = require("q");
|
||||
const paths = require("../npmts.paths");
|
||||
const npmts_log_1 = require("../npmts.log");
|
||||
const plugins = require("./mod00.plugins");
|
||||
exports.run = function (configArg) {
|
||||
let done = q.defer();
|
||||
let config = configArg;
|
||||
npmts_log_1.npmtsOra.text('now compiling ' + 'TypeScript'.yellow);
|
||||
plugins.tsn.compileGlobStringObject(config.ts, config.tsOptions, paths.cwd)
|
||||
.then(() => {
|
||||
plugins.beautylog.ok('compiled main TypeScript!');
|
||||
plugins.beautylog.log('now compiling tests!');
|
||||
return plugins.tsn.compileGlobStringObject(config.testTs, config.tsOptions, paths.cwd);
|
||||
})
|
||||
.then(function () {
|
||||
plugins.beautylog.ok('compiled all TypeScript!');
|
||||
done.resolve(config);
|
||||
}).catch(err => { console.log(err); });
|
||||
return done.promise;
|
||||
};
|
6
dist/mod00/mod00.plugins.d.ts
vendored
Normal file
6
dist/mod00/mod00.plugins.d.ts
vendored
Normal file
@ -0,0 +1,6 @@
|
||||
export * from '../npmts.plugins';
|
||||
import * as tsn from 'tsn';
|
||||
import * as shelljs from 'shelljs';
|
||||
import * as smartchok from 'smartchok';
|
||||
import * as smartstream from 'smartstream';
|
||||
export { tsn, shelljs, smartchok, smartstream };
|
13
dist/mod00/mod00.plugins.js
vendored
Normal file
13
dist/mod00/mod00.plugins.js
vendored
Normal file
@ -0,0 +1,13 @@
|
||||
"use strict";
|
||||
function __export(m) {
|
||||
for (var p in m) if (!exports.hasOwnProperty(p)) exports[p] = m[p];
|
||||
}
|
||||
__export(require("../npmts.plugins"));
|
||||
const tsn = require("tsn");
|
||||
exports.tsn = tsn;
|
||||
const shelljs = require("shelljs");
|
||||
exports.shelljs = shelljs;
|
||||
const smartchok = require("smartchok");
|
||||
exports.smartchok = smartchok;
|
||||
const smartstream = require("smartstream");
|
||||
exports.smartstream = smartstream;
|
Reference in New Issue
Block a user