@magicspace/core
Advanced tools
Comparing version 0.1.5 to 0.2.0
@@ -1,1 +0,16 @@ | ||
export declare function requireDefault<T>(path: string): T; | ||
export declare function unique<T>(values: T[]): T[]; | ||
export declare function uniqueBy<T, TKey>(values: T[], keyCallback: (value: T) => TKey): T[]; | ||
export declare class SpawnSyncFailure { | ||
readonly stdout: string; | ||
readonly stderr: string; | ||
readonly code: number | null; | ||
constructor(stdout: string, stderr: string, code: number | null); | ||
} | ||
export declare function spawnSync(cwd: string, command: string, args: string[]): string; | ||
/** | ||
* Move directory content without conflict. | ||
* | ||
* @returns `true` if content completely moved, otherwise `false`. | ||
*/ | ||
export declare function conservativelyMove(from: string, to: string): boolean; | ||
export declare function getClosetExistingUpperDirectory(path: string): string | undefined; |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.getClosetExistingUpperDirectory = exports.conservativelyMove = exports.spawnSync = exports.SpawnSyncFailure = exports.uniqueBy = exports.unique = void 0; | ||
const tslib_1 = require("tslib"); | ||
function requireDefault(path) { | ||
return tslib_1.__importDefault(require(path)).default; | ||
const ChildProcess = tslib_1.__importStar(require("child_process")); | ||
const Path = tslib_1.__importStar(require("path")); | ||
const FSExtra = tslib_1.__importStar(require("fs-extra")); | ||
function unique(values) { | ||
return Array.from(new Set(values)); | ||
} | ||
exports.requireDefault = requireDefault; | ||
exports.unique = unique; | ||
function uniqueBy(values, keyCallback) { | ||
let map = new Map(); | ||
for (let value of values) { | ||
let key = keyCallback(value); | ||
if (!map.has(key)) { | ||
map.set(key, value); | ||
} | ||
} | ||
return Array.from(map.values()); | ||
} | ||
exports.uniqueBy = uniqueBy; | ||
class SpawnSyncFailure { | ||
constructor(stdout, stderr, code) { | ||
this.stdout = stdout; | ||
this.stderr = stderr; | ||
this.code = code; | ||
} | ||
} | ||
exports.SpawnSyncFailure = SpawnSyncFailure; | ||
function spawnSync(cwd, command, args) { | ||
let { error, status, stdout, stderr } = ChildProcess.spawnSync(command, args, { | ||
cwd, | ||
encoding: 'utf8', | ||
}); | ||
if (error) { | ||
throw error; | ||
} | ||
if (status !== 0) { | ||
throw new SpawnSyncFailure(stdout, stderr, status); | ||
} | ||
return stdout; | ||
} | ||
exports.spawnSync = spawnSync; | ||
/** | ||
* Move directory content without conflict. | ||
* | ||
* @returns `true` if content completely moved, otherwise `false`. | ||
*/ | ||
function conservativelyMove(from, to) { | ||
if (FSExtra.existsSync(to)) { | ||
if (FSExtra.statSync(to).isDirectory()) { | ||
let names = FSExtra.readdirSync(from); | ||
let completelyMoved = names | ||
.map(name => conservativelyMove(Path.join(from, name), Path.join(to, name))) | ||
.every(result => result); | ||
if (completelyMoved) { | ||
FSExtra.rmdirSync(from); | ||
} | ||
return true; | ||
} | ||
else { | ||
return false; | ||
} | ||
} | ||
else { | ||
FSExtra.moveSync(from, to); | ||
return true; | ||
} | ||
} | ||
exports.conservativelyMove = conservativelyMove; | ||
function getClosetExistingUpperDirectory(path) { | ||
while (!FSExtra.existsSync(path)) { | ||
let upperPath = Path.dirname(path); | ||
if (upperPath === path) { | ||
return undefined; | ||
} | ||
path = upperPath; | ||
} | ||
return path; | ||
} | ||
exports.getClosetExistingUpperDirectory = getClosetExistingUpperDirectory; | ||
//# sourceMappingURL=@utils.js.map |
@@ -1,2 +0,1 @@ | ||
export * from './template-bundle-config'; | ||
export * from './project-config'; | ||
export * as Config from './namespace'; |
"use strict"; | ||
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) { | ||
if (k2 === undefined) k2 = k; | ||
Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } }); | ||
}) : (function(o, m, k, k2) { | ||
if (k2 === undefined) k2 = k; | ||
o[k2] = m[k]; | ||
})); | ||
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) { | ||
Object.defineProperty(o, "default", { enumerable: true, value: v }); | ||
}) : function(o, v) { | ||
o["default"] = v; | ||
}); | ||
var __importStar = (this && this.__importStar) || function (mod) { | ||
if (mod && mod.__esModule) return mod; | ||
var result = {}; | ||
if (mod != null) for (var k in mod) if (k !== "default" && Object.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k); | ||
__setModuleDefault(result, mod); | ||
return result; | ||
}; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
const tslib_1 = require("tslib"); | ||
tslib_1.__exportStar(require("./template-bundle-config"), exports); | ||
exports.Config = __importStar(require("./namespace")); | ||
//# sourceMappingURL=index.js.map |
@@ -0,7 +1,5 @@ | ||
export * from './file'; | ||
export * from './composables'; | ||
export * from './config'; | ||
export * from './magicspace-builder'; | ||
export * from './template'; | ||
export * from './formatter'; | ||
export * from './helpers'; | ||
export * from './ts-node'; | ||
export * from './default-magicspace-builder'; | ||
export * from './global'; | ||
export * from './project'; |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
const tslib_1 = require("tslib"); | ||
tslib_1.__exportStar(require("./file"), exports); | ||
tslib_1.__exportStar(require("./composables"), exports); | ||
tslib_1.__exportStar(require("./config"), exports); | ||
tslib_1.__exportStar(require("./magicspace-builder"), exports); | ||
tslib_1.__exportStar(require("./template"), exports); | ||
tslib_1.__exportStar(require("./formatter"), exports); | ||
tslib_1.__exportStar(require("./helpers"), exports); | ||
tslib_1.__exportStar(require("./ts-node"), exports); | ||
tslib_1.__exportStar(require("./default-magicspace-builder"), exports); | ||
tslib_1.__exportStar(require("./global"), exports); | ||
tslib_1.__exportStar(require("./project"), exports); | ||
//# sourceMappingURL=index.js.map |
{ | ||
"name": "@magicspace/core", | ||
"version": "0.1.5", | ||
"version": "0.2.0", | ||
"description": "", | ||
@@ -22,21 +22,17 @@ "author": "Chengdu Mufan Technology Co., Ltd.", | ||
"dependencies": { | ||
"fs-extra": "^8.1.0", | ||
"glob": "^7.1.4", | ||
"handlebars": "^4.1.2", | ||
"lodash": "^4.17.14", | ||
"prettier": "^1.18.2", | ||
"resolve": "^1.11.1", | ||
"sort-keys": "^3.0.0", | ||
"strip-json-comments": "^3.0.1", | ||
"ts-node": "^8.3.0", | ||
"tslang": "^0.1.15", | ||
"tslib": "^1.10.0", | ||
"typescript": "^3.5.3" | ||
"fast-glob": "^3.2.4", | ||
"fs-extra": "^9.0.1", | ||
"handlebars": "^4.7.6", | ||
"module-lens": "^0.1.3", | ||
"prettier": "^2.0.5", | ||
"sort-keys": "^4.0.0", | ||
"tslang": "^0.1.22", | ||
"tslib": "^2.0.1", | ||
"typescript": "^3.9.7" | ||
}, | ||
"devDependencies": { | ||
"@magicspace/tslint-rules": "^0.1.46", | ||
"tslint": "^5.20.1", | ||
"tslint-config-prettier": "^1.18.0" | ||
"@types/fs-extra": "^9.0.1", | ||
"@types/prettier": "^2.0.2" | ||
}, | ||
"gitHead": "3618066b8e42c6fab0c5babedcd96ef1af0bcca3" | ||
"gitHead": "d13f3b74107a3edfa1491970e6a64f1b531532c3" | ||
} |
@@ -1,5 +0,100 @@ | ||
import {__importDefault} from 'tslib'; | ||
import * as ChildProcess from 'child_process'; | ||
import * as Path from 'path'; | ||
export function requireDefault<T>(path: string): T { | ||
return __importDefault(require(path)).default; | ||
import * as FSExtra from 'fs-extra'; | ||
export function unique<T>(values: T[]): T[] { | ||
return Array.from(new Set(values)); | ||
} | ||
export function uniqueBy<T, TKey>( | ||
values: T[], | ||
keyCallback: (value: T) => TKey, | ||
): T[] { | ||
let map = new Map<TKey, T>(); | ||
for (let value of values) { | ||
let key = keyCallback(value); | ||
if (!map.has(key)) { | ||
map.set(key, value); | ||
} | ||
} | ||
return Array.from(map.values()); | ||
} | ||
export class SpawnSyncFailure { | ||
constructor( | ||
readonly stdout: string, | ||
readonly stderr: string, | ||
readonly code: number | null, | ||
) {} | ||
} | ||
export function spawnSync( | ||
cwd: string, | ||
command: string, | ||
args: string[], | ||
): string { | ||
let {error, status, stdout, stderr} = ChildProcess.spawnSync(command, args, { | ||
cwd, | ||
encoding: 'utf8', | ||
}); | ||
if (error) { | ||
throw error; | ||
} | ||
if (status !== 0) { | ||
throw new SpawnSyncFailure(stdout, stderr, status); | ||
} | ||
return stdout; | ||
} | ||
/** | ||
* Move directory content without conflict. | ||
* | ||
* @returns `true` if content completely moved, otherwise `false`. | ||
*/ | ||
export function conservativelyMove(from: string, to: string): boolean { | ||
if (FSExtra.existsSync(to)) { | ||
if (FSExtra.statSync(to).isDirectory()) { | ||
let names = FSExtra.readdirSync(from); | ||
let completelyMoved = names | ||
.map(name => | ||
conservativelyMove(Path.join(from, name), Path.join(to, name)), | ||
) | ||
.every(result => result); | ||
if (completelyMoved) { | ||
FSExtra.rmdirSync(from); | ||
} | ||
return true; | ||
} else { | ||
return false; | ||
} | ||
} else { | ||
FSExtra.moveSync(from, to); | ||
return true; | ||
} | ||
} | ||
export function getClosetExistingUpperDirectory( | ||
path: string, | ||
): string | undefined { | ||
while (!FSExtra.existsSync(path)) { | ||
let upperPath = Path.dirname(path); | ||
if (upperPath === path) { | ||
return undefined; | ||
} | ||
path = upperPath; | ||
} | ||
return path; | ||
} |
@@ -1,2 +0,1 @@ | ||
export * from './template-bundle-config'; | ||
export * from './project-config'; | ||
export * as Config from './namespace'; |
@@ -0,7 +1,5 @@ | ||
export * from './file'; | ||
export * from './composables'; | ||
export * from './config'; | ||
export * from './magicspace-builder'; | ||
export * from './template'; | ||
export * from './formatter'; | ||
export * from './helpers'; | ||
export * from './ts-node'; | ||
export * from './default-magicspace-builder'; | ||
export * from './global'; | ||
export * from './project'; |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
Shell access
Supply chain riskThis module accesses the system shell. Accessing the system shell increases the risk of executing arbitrary code.
Found 1 instance in 1 package
Debug access
Supply chain riskUses debug, reflection and dynamic code execution features.
Found 1 instance in 1 package
Dynamic require
Supply chain riskDynamic require can indicate the package is performing dangerous or unsafe dynamic code execution.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
New author
Supply chain riskA new npm collaborator published a version of the package for the first time. New collaborators are usually benign additions to a project, but do indicate a change to the security surface area of a package.
Found 1 instance in 1 package
Dynamic require
Supply chain riskDynamic require can indicate the package is performing dangerous or unsafe dynamic code execution.
Found 1 instance in 1 package
267074
9
2
2203
112
11
2
+ Addedfast-glob@^3.2.4
+ Addedmodule-lens@^0.1.3
+ Added@nodelib/fs.scandir@2.1.5(transitive)
+ Added@nodelib/fs.stat@2.0.5(transitive)
+ Added@nodelib/fs.walk@1.2.8(transitive)
+ Addedat-least-node@1.0.0(transitive)
+ Addedbraces@3.0.3(transitive)
+ Addedfast-glob@3.3.2(transitive)
+ Addedfastq@1.17.1(transitive)
+ Addedfill-range@7.1.1(transitive)
+ Addedfs-extra@9.1.0(transitive)
+ Addedglob-parent@5.1.2(transitive)
+ Addedis-extglob@2.1.1(transitive)
+ Addedis-glob@4.0.3(transitive)
+ Addedis-number@7.0.0(transitive)
+ Addedjsonfile@6.1.0(transitive)
+ Addedmerge2@1.4.1(transitive)
+ Addedmicromatch@4.0.8(transitive)
+ Addedmodule-lens@0.1.6(transitive)
+ Addedpicomatch@2.3.1(transitive)
+ Addedprettier@2.8.8(transitive)
+ Addedqueue-microtask@1.2.3(transitive)
+ Addedreusify@1.0.4(transitive)
+ Addedrun-parallel@1.2.0(transitive)
+ Addedsort-keys@4.2.0(transitive)
+ Addedto-regex-range@5.0.1(transitive)
+ Addedtslib@2.8.1(transitive)
+ Addeduniversalify@2.0.1(transitive)
- Removedglob@^7.1.4
- Removedlodash@^4.17.14
- Removedresolve@^1.11.1
- Removedstrip-json-comments@^3.0.1
- Removedts-node@^8.3.0
- Removedarg@4.1.3(transitive)
- Removedbalanced-match@1.0.2(transitive)
- Removedbrace-expansion@1.1.11(transitive)
- Removedbuffer-from@1.1.2(transitive)
- Removedconcat-map@0.0.1(transitive)
- Removeddiff@4.0.2(transitive)
- Removedfs-extra@8.1.0(transitive)
- Removedfs.realpath@1.0.0(transitive)
- Removedfunction-bind@1.1.2(transitive)
- Removedglob@7.2.3(transitive)
- Removedhasown@2.0.2(transitive)
- Removedinflight@1.0.6(transitive)
- Removedinherits@2.0.4(transitive)
- Removedis-core-module@2.15.1(transitive)
- Removedjsonfile@4.0.0(transitive)
- Removedlodash@4.17.21(transitive)
- Removedmake-error@1.3.6(transitive)
- Removedminimatch@3.1.2(transitive)
- Removedonce@1.4.0(transitive)
- Removedpath-is-absolute@1.0.1(transitive)
- Removedpath-parse@1.0.7(transitive)
- Removedprettier@1.19.1(transitive)
- Removedresolve@1.22.8(transitive)
- Removedsort-keys@3.0.0(transitive)
- Removedsource-map-support@0.5.21(transitive)
- Removedstrip-json-comments@3.1.1(transitive)
- Removedsupports-preserve-symlinks-flag@1.0.0(transitive)
- Removedts-node@8.10.2(transitive)
- Removedtslib@1.14.1(transitive)
- Removeduniversalify@0.1.2(transitive)
- Removedwrappy@1.0.2(transitive)
- Removedyn@3.1.1(transitive)
Updatedfs-extra@^9.0.1
Updatedhandlebars@^4.7.6
Updatedprettier@^2.0.5
Updatedsort-keys@^4.0.0
Updatedtslang@^0.1.22
Updatedtslib@^2.0.1
Updatedtypescript@^3.9.7