Added initial project files
Signed-off-by: boris <boris.karastanev@progress.com>
This commit is contained in:
Родитель
661409e891
Коммит
fafdabad57
|
@ -0,0 +1,65 @@
|
|||
# Created by .ignore support plugin (hsz.mobi)
|
||||
### Node template
|
||||
# Logs
|
||||
logs
|
||||
*.log
|
||||
npm-debug.log*
|
||||
yarn-debug.log*
|
||||
yarn-error.log*
|
||||
|
||||
# Runtime data
|
||||
pids
|
||||
*.pid
|
||||
*.seed
|
||||
*.pid.lock
|
||||
|
||||
# Directory for instrumented libs generated by jscoverage/JSCover
|
||||
lib-cov
|
||||
|
||||
# Coverage directory used by tools like istanbul
|
||||
coverage
|
||||
|
||||
# nyc test coverage
|
||||
.nyc_output
|
||||
|
||||
# Grunt intermediate storage (http://gruntjs.com/creating-plugins#storing-task-files)
|
||||
.grunt
|
||||
|
||||
# Bower dependency directory (https://bower.io/)
|
||||
bower_components
|
||||
|
||||
# node-waf configuration
|
||||
.lock-wscript
|
||||
|
||||
# Compiled binary addons (http://nodejs.org/api/addons.html)
|
||||
build/Release
|
||||
|
||||
# Dependency directories
|
||||
node_modules/
|
||||
jspm_packages/
|
||||
|
||||
# Typescript v1 declaration files
|
||||
typings/
|
||||
|
||||
# Optional npm cache directory
|
||||
.npm
|
||||
|
||||
# Optional eslint cache
|
||||
.eslintcache
|
||||
|
||||
# Optional REPL history
|
||||
.node_repl_history
|
||||
|
||||
# Output of 'npm pack'
|
||||
*.tgz
|
||||
|
||||
# Yarn Integrity file
|
||||
.yarn-integrity
|
||||
|
||||
# dotenv environment variables file
|
||||
.env
|
||||
|
||||
# ignore ide dir
|
||||
.idea
|
||||
|
||||
|
|
@ -0,0 +1,254 @@
|
|||
"use strict";
|
||||
|
||||
const path = require("path");
|
||||
const fs = require("fs");
|
||||
const childProcess = require("child_process");
|
||||
const _ = require("lodash");
|
||||
const os = require("os");
|
||||
const nodeArgs = [];
|
||||
const getBuildVersion = (version) => {
|
||||
let buildVersion = version !== undefined ? version : process.env["BUILD_NUMBER"];
|
||||
if (process.env["BUILD_CAUSE_GHPRBCAUSE"]) {
|
||||
buildVersion = "PR" + buildVersion;
|
||||
}
|
||||
|
||||
return buildVersion;
|
||||
}
|
||||
|
||||
module.exports = function (grunt) {
|
||||
|
||||
// Windows cmd does not accept paths with / and unix shell does not accept paths with \\ and we need to execute from a sub-dir.
|
||||
// To circumvent the issue, hack our environment's PATH and let the OS deal with it, which in practice works
|
||||
process.env.path = process.env.path + (os.platform() === "win32" ? ";" : ":") + "node_modules/.bin";
|
||||
|
||||
const defaultEnvironment = "sit";
|
||||
|
||||
grunt.initConfig({
|
||||
deploymentEnvironment: process.env["DeploymentEnvironment"] || defaultEnvironment,
|
||||
resourceDownloadEnvironment: process.env["ResourceDownloadEnvironment"] || defaultEnvironment,
|
||||
jobName: process.env["JOB_NAME"] || defaultEnvironment,
|
||||
buildNumber: process.env["BUILD_NUMBER"] || "non-ci",
|
||||
|
||||
pkg: grunt.file.readJSON("package.json"),
|
||||
ts: {
|
||||
options: grunt.file.readJSON("tsconfig.json").compilerOptions,
|
||||
|
||||
devlib: {
|
||||
src: ["lib/**/*.ts", "test/**/*.ts", "references.d.ts", "!node_modules/**/*"]
|
||||
},
|
||||
|
||||
release_build: {
|
||||
src: ["lib/**/*.ts", "test/**/*.ts", "references.d.ts", "!node_modules/**/*"],
|
||||
options: {
|
||||
sourceMap: false,
|
||||
removeComments: true
|
||||
}
|
||||
}
|
||||
},
|
||||
|
||||
tslint: {
|
||||
build: {
|
||||
files: {
|
||||
src: ["lib/**/*.ts", "test/**/*.ts", "definitions/**/*.ts"]
|
||||
},
|
||||
options: {
|
||||
configuration: grunt.file.readJSON("./tslint.json")
|
||||
}
|
||||
}
|
||||
},
|
||||
|
||||
watch: {
|
||||
devall: {
|
||||
files: ["lib/**/*.ts", "test/**/*.ts"],
|
||||
tasks: ['ts:devlib'],
|
||||
options: {
|
||||
atBegin: true,
|
||||
interrupt: true
|
||||
}
|
||||
}
|
||||
},
|
||||
|
||||
shell: {
|
||||
options: {
|
||||
stdout: true,
|
||||
stderr: true
|
||||
},
|
||||
|
||||
ci_unit_tests: {
|
||||
command: "npm test",
|
||||
options: {
|
||||
execOptions: {
|
||||
env: (function () {
|
||||
var env = _.cloneDeep(process.env);
|
||||
env["XUNIT_FILE"] = "test-reports.xml";
|
||||
env["LOG_XUNIT"] = "true";
|
||||
return env;
|
||||
})()
|
||||
}
|
||||
}
|
||||
},
|
||||
|
||||
apply_deployment_environment: {
|
||||
command: "node " + nodeArgs.join(" ") + " bin/appbuilder dev-config-apply <%= deploymentEnvironment %>"
|
||||
},
|
||||
|
||||
build_package: {
|
||||
command: "npm pack",
|
||||
options: {
|
||||
execOptions: {
|
||||
env: (function () {
|
||||
var env = _.cloneDeep(process.env);
|
||||
env["APPBUILDER_SKIP_POSTINSTALL_TASKS"] = "1";
|
||||
return env;
|
||||
})()
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
|
||||
clean: {
|
||||
src: ["test/**/*.js*",
|
||||
"lib/**/*.js*",
|
||||
"*.tgz"]
|
||||
}
|
||||
});
|
||||
|
||||
grunt.loadNpmTasks("grunt-contrib-clean");
|
||||
grunt.loadNpmTasks("grunt-contrib-watch");
|
||||
grunt.loadNpmTasks("grunt-shell");
|
||||
grunt.loadNpmTasks("grunt-ts");
|
||||
grunt.loadNpmTasks("grunt-tslint");
|
||||
|
||||
grunt.registerTask("set_package_version", function (version) {
|
||||
const buildVersion = getBuildVersion(version);
|
||||
const packageJson = grunt.file.readJSON("package.json");
|
||||
packageJson.buildVersion = buildVersion;
|
||||
grunt.file.write("package.json", JSON.stringify(packageJson, null, " "));
|
||||
});
|
||||
|
||||
const transpileProject = function (dirname) {
|
||||
const pathToModule = path.join(__dirname, "node_modules", dirname);
|
||||
const packageJsonContent = grunt.file.readJSON(path.join(pathToModule, "package.json"));
|
||||
|
||||
try {
|
||||
// Keep the --production flag - in case we skip it, we'll instal istanbul, chai, etc. and their .d.ts will conflict with ours.
|
||||
childProcess.execSync("npm i --ignore-scripts --production", { cwd: pathToModule, stdio: "ignore" });
|
||||
} catch (err) {
|
||||
}
|
||||
|
||||
try {
|
||||
// grunt deps must be installed locally in the project where grunt will be called.
|
||||
// also for transpilation we need typescript locally.
|
||||
const searchedNames = ["grunt", "typescript"];
|
||||
const dependenciesToInstall = _.map(packageJsonContent.devDependencies, (version, name) => {
|
||||
for (let searchedName of searchedNames) {
|
||||
if (name.indexOf(searchedName) !== -1 && !fs.existsSync(path.join(pathToModule, "node_modules", name))) {
|
||||
return `${name}@${version}`
|
||||
}
|
||||
}
|
||||
}).filter(a => !!a);
|
||||
|
||||
_.each(dependenciesToInstall, name => {
|
||||
try {
|
||||
childProcess.execSync(`npm i --ignore-scripts --production ${name}`, { cwd: pathToModule, stdio: "ignore" });
|
||||
} catch (err) {
|
||||
}
|
||||
})
|
||||
|
||||
|
||||
} catch (err) { }
|
||||
|
||||
try {
|
||||
// we need the .js file in the tests, so we can require them, for example in order to create a new instance of injector.
|
||||
// if the main file is .js and it exists, no need to transpile it again
|
||||
const pathToMain = path.join(pathToModule, packageJsonContent.main);
|
||||
if (!fs.existsSync(pathToMain)) {
|
||||
childProcess.execSync("grunt", { cwd: pathToModule, stdio: "ignore" });
|
||||
}
|
||||
} catch (err) { }
|
||||
};
|
||||
|
||||
grunt.registerTask("transpile_additional_project", function () {
|
||||
transpileProject("nativescript");
|
||||
transpileProject("mobile-cli-lib");
|
||||
transpileProject("ios-device-lib");
|
||||
});
|
||||
|
||||
grunt.registerTask("setPackageName", function (version) {
|
||||
const fs = require("fs");
|
||||
const fileExtension = ".tgz";
|
||||
const buildVersion = getBuildVersion(version);
|
||||
const packageJson = grunt.file.readJSON("package.json");
|
||||
const oldFileName = packageJson.name + "-" + packageJson.version;
|
||||
const newFileName = oldFileName + "-" + buildVersion;
|
||||
fs.renameSync(oldFileName + fileExtension, newFileName + fileExtension);
|
||||
});
|
||||
|
||||
grunt.registerTask("delete_coverage_dir", function () {
|
||||
const done = this.async();
|
||||
const rimraf = require("rimraf");
|
||||
rimraf("coverage", function (err) {
|
||||
if (err) {
|
||||
console.log("Error while deleting coverage directory from the package.");
|
||||
done(false);
|
||||
}
|
||||
|
||||
done();
|
||||
});
|
||||
});
|
||||
|
||||
grunt.registerTask("test", ["transpile_additional_project", "generate_references", "ts:devlib", "shell:ci_unit_tests"]);
|
||||
|
||||
grunt.registerTask("generate_references", () => {
|
||||
const referencesPath = path.join(__dirname, "references.d.ts");
|
||||
|
||||
// get all .d.ts files from nativescript-cli and mobile-cli-lib
|
||||
const nodeModulesDirPath = path.join(__dirname, "node_modules");
|
||||
const pathsOfDtsFiles = getReferencesFromDir(path.join(nodeModulesDirPath, "nativescript"))
|
||||
.concat(getReferencesFromDir(path.join(nodeModulesDirPath, "mobile-cli-lib")))
|
||||
.concat(getReferencesFromDir(path.join(nodeModulesDirPath, "ios-device-lib")));
|
||||
|
||||
const lines = pathsOfDtsFiles.map(file => `/// <reference path="${fromWindowsRelativePathToUnix(path.relative(__dirname, file))}" />`);
|
||||
|
||||
fs.writeFileSync(referencesPath, lines.join(os.EOL));
|
||||
});
|
||||
|
||||
const fromWindowsRelativePathToUnix = (windowsRelativePath) => {
|
||||
return windowsRelativePath.replace(/\\/g, "/");
|
||||
}
|
||||
|
||||
// returns paths that have to be added to reference.d.ts.
|
||||
const getReferencesFromDir = (dir) => {
|
||||
const currentDirContent = fs.readdirSync(dir).map(item => path.join(dir, item));
|
||||
let pathsToDtsFiles = [];
|
||||
_.each(currentDirContent, d => {
|
||||
const stat = fs.statSync(d);
|
||||
if (stat.isDirectory() && path.basename(d) !== "node_modules") {
|
||||
// recursively check all dirs for .d.ts files.
|
||||
pathsToDtsFiles = pathsToDtsFiles.concat(getReferencesFromDir(d));
|
||||
} else if (stat.isFile() && d.endsWith(".d.ts") && path.basename(d) !== ".d.ts") {
|
||||
pathsToDtsFiles.push(d);
|
||||
}
|
||||
});
|
||||
|
||||
return pathsToDtsFiles;
|
||||
};
|
||||
|
||||
grunt.registerTask("pack", [
|
||||
"clean",
|
||||
"generate_references",
|
||||
"ts:release_build",
|
||||
"transpile_additional_project",
|
||||
"shell:ci_unit_tests",
|
||||
"tslint:build",
|
||||
|
||||
"set_package_version",
|
||||
"delete_coverage_dir",
|
||||
"shell:build_package",
|
||||
"setPackageName"
|
||||
]);
|
||||
grunt.registerTask("lint", ["tslint:build"]);
|
||||
grunt.registerTask("all", ["clean", "test", "lint"]);
|
||||
grunt.registerTask("rebuild", ["clean", "ts:devlib"]);
|
||||
grunt.registerTask("default", ["generate_references", "ts:devlib"]);
|
||||
};
|
|
@ -0,0 +1,48 @@
|
|||
{
|
||||
"name": "ui-kits-cli-extension",
|
||||
"version": "0.0.1",
|
||||
"description": "CLI extension for the NatvieScript CLI",
|
||||
"main": "lib/bootstrap.js",
|
||||
"scripts": {},
|
||||
"repository": {},
|
||||
"author": "Progress <support@telerik.com>",
|
||||
"license": "Apache-2.0",
|
||||
"bugs": {},
|
||||
"devDependencies": {
|
||||
"@types/chai": "3.4.34",
|
||||
"@types/chai-as-promised": "0.0.29",
|
||||
"@types/lodash": "4.14.50",
|
||||
"@types/node": "6.0.61",
|
||||
"@types/node-forge": "0.6.7",
|
||||
"@types/semver": "5.3.30",
|
||||
"@types/source-map": "0.5.0",
|
||||
"@types/uuid": "2.0.29",
|
||||
"chai": "3.5.0",
|
||||
"chai-as-promised": "6.0.0",
|
||||
"grunt": "1.0.1",
|
||||
"grunt-contrib-clean": "1.0.0",
|
||||
"grunt-contrib-copy": "1.0.0",
|
||||
"grunt-contrib-watch": "1.0.0",
|
||||
"grunt-shell": "1.3.0",
|
||||
"grunt-ts": "6.0.0-beta.11",
|
||||
"grunt-tslint": "4.0.1",
|
||||
"istanbul": "0.4.5",
|
||||
"mobile-cli-lib": "https://github.com/telerik/mobile-cli-lib/tarball/master",
|
||||
"mocha": "3.1.2",
|
||||
"mocha-typescript": "^1.0.4",
|
||||
"nativescript": "https://github.com/NativeScript/nativescript-cli/tarball/master",
|
||||
"should": "7.0.2",
|
||||
"spec-xunit-file": "0.0.1-3",
|
||||
"tslint": "4.3.1",
|
||||
"typescript": "2.1.5"
|
||||
},
|
||||
"dependencies": {
|
||||
"cookie": "0.3.1",
|
||||
"lodash": "4.17.4",
|
||||
"node-forge": "0.7.0",
|
||||
"querystring": "0.2.0",
|
||||
"semver": "5.3.0",
|
||||
"simple-plist": "0.2.1",
|
||||
"uuid": "3.0.1"
|
||||
}
|
||||
}
|
|
@ -0,0 +1,19 @@
|
|||
{
|
||||
"compilerOptions": {
|
||||
"target": "es6",
|
||||
"module": "commonjs",
|
||||
"sourceMap": true,
|
||||
"declaration": false,
|
||||
"removeComments": false,
|
||||
"noImplicitAny": true,
|
||||
"experimentalDecorators": true,
|
||||
"noUnusedLocals": true,
|
||||
"alwaysStrict": true,
|
||||
"noEmitOnError": false
|
||||
},
|
||||
"exclude": [
|
||||
"node_modules",
|
||||
"scratch",
|
||||
"coverage"
|
||||
]
|
||||
}
|
|
@ -0,0 +1,71 @@
|
|||
{
|
||||
"rules": {
|
||||
"class-name": true,
|
||||
"curly": true,
|
||||
"eofline": true,
|
||||
"indent": [
|
||||
true,
|
||||
"tabs"
|
||||
],
|
||||
"interface-name": true,
|
||||
"jsdoc-format": true,
|
||||
"max-line-length": [
|
||||
false,
|
||||
140
|
||||
],
|
||||
"no-consecutive-blank-lines": true,
|
||||
"no-construct": true,
|
||||
"no-debugger": true,
|
||||
"no-duplicate-variable": true,
|
||||
"no-shadowed-variable": true,
|
||||
"no-empty": true,
|
||||
"no-eval": true,
|
||||
"no-switch-case-fall-through": true,
|
||||
"no-trailing-whitespace": true,
|
||||
"no-unused-expression": true,
|
||||
"no-use-before-declare": true,
|
||||
"no-var-keyword": true,
|
||||
"no-var-requires": false,
|
||||
"one-line": [
|
||||
true,
|
||||
"check-catch",
|
||||
"check-finally",
|
||||
"check-else",
|
||||
"check-open-brace",
|
||||
"check-whitespace"
|
||||
],
|
||||
"quotemark": [
|
||||
false,
|
||||
"double"
|
||||
],
|
||||
"semicolon": true,
|
||||
"space-before-function-paren": false,
|
||||
"switch-default": false,
|
||||
"trailing-comma": [
|
||||
false,
|
||||
{
|
||||
"multiline": "always",
|
||||
"singleline": "always"
|
||||
}
|
||||
],
|
||||
"triple-equals": [
|
||||
true,
|
||||
"allow-null-check"
|
||||
],
|
||||
"typeof-compare": true,
|
||||
"use-isnan": true,
|
||||
"variable-name": [
|
||||
true,
|
||||
"ban-keywords",
|
||||
"allow-leading-underscore"
|
||||
],
|
||||
"whitespace": [
|
||||
true,
|
||||
"check-branch",
|
||||
"check-decl",
|
||||
"check-operator",
|
||||
"check-module",
|
||||
"check-separator"
|
||||
]
|
||||
}
|
||||
}
|
Загрузка…
Ссылка в новой задаче