Compare commits
47 Commits
Author | SHA1 | Date | |
---|---|---|---|
618b3da86e | |||
482bc6c18e | |||
ac988b9b09 | |||
0b6c83a806 | |||
37cbf0f8c8 | |||
29decabf91 | |||
afcb5d5b0c | |||
53905df003 | |||
09d424e972 | |||
f66864d0af | |||
930d90345a | |||
39835a4d27 | |||
13c001c48a | |||
7916929550 | |||
c52c1902ee | |||
06c60d42c1 | |||
38668239d4 | |||
3d0257768d | |||
e09ce0edc0 | |||
3d4c2e64b4 | |||
139478965b | |||
1e545a2cfb | |||
10b593b480 | |||
839a86ccf1 | |||
06ebd44189 | |||
3d5aa9fda7 | |||
cc5f57da44 | |||
2866a76abc | |||
a8f93682fc | |||
2833666d14 | |||
0ca312bd02 | |||
a8f53ae2ae | |||
5b7f104c88 | |||
f2423f7c61 | |||
57680424c4 | |||
04b942092c | |||
209ff095a4 | |||
fb62b0aac7 | |||
736eefa91e | |||
8fc994737b | |||
32e478ef4e | |||
451e2e241f | |||
202914b19b | |||
373a4eed94 | |||
9a9f28bdff | |||
2bd242ac57 | |||
b113dcfbe0 |
26
.gitignore
vendored
26
.gitignore
vendored
@ -1,8 +1,20 @@
|
|||||||
|
.nogit/
|
||||||
|
|
||||||
|
# artifacts
|
||||||
|
coverage/
|
||||||
|
public/
|
||||||
|
pages/
|
||||||
|
|
||||||
|
# installs
|
||||||
node_modules/
|
node_modules/
|
||||||
.settings/
|
|
||||||
.idea/
|
# caches
|
||||||
docs/
|
.yarn/
|
||||||
ts/typings/
|
.cache/
|
||||||
ts/**/*.js
|
.rpt2_cache
|
||||||
ts/**/*.js.map
|
|
||||||
coverage/
|
# builds
|
||||||
|
dist/
|
||||||
|
dist_*/
|
||||||
|
|
||||||
|
# custom
|
127
.gitlab-ci.yml
Normal file
127
.gitlab-ci.yml
Normal file
@ -0,0 +1,127 @@
|
|||||||
|
# gitzone ci_default
|
||||||
|
image: registry.gitlab.com/hosttoday/ht-docker-node:npmci
|
||||||
|
|
||||||
|
cache:
|
||||||
|
paths:
|
||||||
|
- .npmci_cache/
|
||||||
|
key: '$CI_BUILD_STAGE'
|
||||||
|
|
||||||
|
stages:
|
||||||
|
- security
|
||||||
|
- test
|
||||||
|
- release
|
||||||
|
- metadata
|
||||||
|
|
||||||
|
# ====================
|
||||||
|
# security stage
|
||||||
|
# ====================
|
||||||
|
mirror:
|
||||||
|
stage: security
|
||||||
|
script:
|
||||||
|
- npmci git mirror
|
||||||
|
tags:
|
||||||
|
- lossless
|
||||||
|
- docker
|
||||||
|
- notpriv
|
||||||
|
|
||||||
|
audit:
|
||||||
|
image: registry.gitlab.com/hosttoday/ht-docker-node:npmci
|
||||||
|
stage: security
|
||||||
|
script:
|
||||||
|
- npmci npm prepare
|
||||||
|
- npmci command npm install --ignore-scripts
|
||||||
|
- npmci command npm config set registry https://registry.npmjs.org
|
||||||
|
- npmci command npm audit --audit-level=high
|
||||||
|
tags:
|
||||||
|
- lossless
|
||||||
|
- docker
|
||||||
|
- notpriv
|
||||||
|
|
||||||
|
# ====================
|
||||||
|
# test stage
|
||||||
|
# ====================
|
||||||
|
|
||||||
|
testStable:
|
||||||
|
stage: test
|
||||||
|
script:
|
||||||
|
- npmci npm prepare
|
||||||
|
- npmci node install stable
|
||||||
|
- npmci npm install
|
||||||
|
- npmci npm test
|
||||||
|
coverage: /\d+.?\d+?\%\s*coverage/
|
||||||
|
tags:
|
||||||
|
- lossless
|
||||||
|
- docker
|
||||||
|
- priv
|
||||||
|
|
||||||
|
testBuild:
|
||||||
|
stage: test
|
||||||
|
script:
|
||||||
|
- npmci npm prepare
|
||||||
|
- npmci node install stable
|
||||||
|
- npmci npm install
|
||||||
|
- npmci command npm run build
|
||||||
|
coverage: /\d+.?\d+?\%\s*coverage/
|
||||||
|
tags:
|
||||||
|
- lossless
|
||||||
|
- docker
|
||||||
|
- notpriv
|
||||||
|
|
||||||
|
release:
|
||||||
|
stage: release
|
||||||
|
script:
|
||||||
|
- npmci node install stable
|
||||||
|
- npmci npm publish
|
||||||
|
only:
|
||||||
|
- tags
|
||||||
|
tags:
|
||||||
|
- lossless
|
||||||
|
- docker
|
||||||
|
- notpriv
|
||||||
|
|
||||||
|
# ====================
|
||||||
|
# metadata stage
|
||||||
|
# ====================
|
||||||
|
codequality:
|
||||||
|
stage: metadata
|
||||||
|
allow_failure: true
|
||||||
|
script:
|
||||||
|
- npmci command npm install -g tslint typescript
|
||||||
|
- npmci npm prepare
|
||||||
|
- npmci npm install
|
||||||
|
- npmci command "tslint -c tslint.json ./ts/**/*.ts"
|
||||||
|
tags:
|
||||||
|
- lossless
|
||||||
|
- docker
|
||||||
|
- priv
|
||||||
|
|
||||||
|
trigger:
|
||||||
|
stage: metadata
|
||||||
|
script:
|
||||||
|
- npmci trigger
|
||||||
|
only:
|
||||||
|
- tags
|
||||||
|
tags:
|
||||||
|
- lossless
|
||||||
|
- docker
|
||||||
|
- notpriv
|
||||||
|
|
||||||
|
pages:
|
||||||
|
stage: metadata
|
||||||
|
script:
|
||||||
|
- npmci node install lts
|
||||||
|
- npmci command npm install -g @gitzone/tsdoc
|
||||||
|
- npmci npm prepare
|
||||||
|
- npmci npm install
|
||||||
|
- npmci command tsdoc
|
||||||
|
tags:
|
||||||
|
- lossless
|
||||||
|
- docker
|
||||||
|
- notpriv
|
||||||
|
only:
|
||||||
|
- tags
|
||||||
|
artifacts:
|
||||||
|
expire_in: 1 week
|
||||||
|
paths:
|
||||||
|
- public
|
||||||
|
allow_failure: true
|
19
.travis.yml
19
.travis.yml
@ -1,19 +0,0 @@
|
|||||||
language: node_js
|
|
||||||
before_install:
|
|
||||||
- nvm install stable
|
|
||||||
- node -v
|
|
||||||
- npm -v
|
|
||||||
- npm install -g gulp
|
|
||||||
- npm install gulp
|
|
||||||
- npm install gulp-typescript
|
|
||||||
deploy:
|
|
||||||
provider: npm
|
|
||||||
email: npm@lossless.digital
|
|
||||||
api_key:
|
|
||||||
secure: C21gKjjg4W61RQlDo9vCjXjJ5NRvEoLuKe8IcKrTXEnn5R3ewnHfpgAQtXuBLvYuP6mIS6N2UxhcIo3BpsII1oOC4iJ4i3wqf6CH9hkmD1ejJe7qRiMKxltN0/4DHioySuolfcimKnOKSMGNQpOnze9lxqNi/qjUIgdsEY7soJRLIR9JQmhBBcRHoSzhxm6AnDmgEO75QsDIyhDH4wkWkOCOhRhjSfFNI6rm/om0XBRYkCKeNfz+Oqosnr8EkMVzsiRebLLXwZxzyCGSVFYQobtLxVqZDK5fvcz/GPyCbpDG/pZq5lxEkFYRiq+OmlIQn9Hz4C0i8VlXevS0ZatwS9iCGmG0/4ayUc2ksasY8o+bUfPJju0vKsCJJhtIj1e4GEj0ubisKirBOb5Oj8tMdf9RGLeNztFKRZEaM/ZoJ0gN//R9p4vWUZGMqJeIWh4I0hXA5Lv2OTUSl2h9bJ+Z678cb1k40w8bEVOij9GnUGQHybNwXV+8LZckap29/XDxguxtnYnuoX7L/dUfjkhK6JQRS9c7NDWOSzsnsy5kx0jHNaHac7vxMzmbdSRK71rNkzudtu2ECxONDc8aUNJLmUfL1tgYWt9/t9ramBqtmpp3w0S+s82PDHtoxAn02lWi2pz8pSp9ACP105qtUD9/1TCWtQUbYoL00QhFmlKzWwg=
|
|
||||||
on:
|
|
||||||
tags: true
|
|
||||||
repo: pushrocks/smartpath
|
|
||||||
notifications:
|
|
||||||
slack:
|
|
||||||
secure: f5Uss0z9RPl/QcA/DroB8loyE93aOYI6bqCkrsiUscmZtlv/TVQtT4dxqGA6uvcG6iTQDBi3Ul88dQxWkRm4IqbhY35/iMaV2dHW4FVYMAh8GQMbsfL2sALCcufxD9blw47awv3iFcwhV1EeyesscjgL0JIjduk96v/7G/6QIO2838M1lzlgtj+kRUkim8qkaEs1je3gRrhMUIjLuAdscMXyUKYFMjWo9ACSjVUl30R/ZNemb18itIja6i92GotreBgcfEMczvy58ovDC7xdJUsY8LjMI01DwY+WPRnI0tAhsuI8moBwwcdM4e3bAjKjucQRjO33O5bMWRZ6QCiYd0DnCEFyCPQLJ4GSy/tkD00n8ijLHAOSV3AH1zNbdK1EAdSPQXDvlI36KJn/2hyQLoitGHVUPr76ujJWP82ypO2tgIp3XQU0dJVCxDuHnwJO2+hjdI+gCPqxNTpjeujHx3UdkTGNRjuuf9dlZ/D08fApjYxy2fxItTqo3QjP/nrqvBXUOPP8yPHpjIT4H2t5Pr4SJjBGI6X4qhKyFj6s9rA/Xu1rL+45zu1C3uC3z+u3T9UwrbzJ/cZM6r6UQvQmUvIfBNaMlg4I/diQCDIPL+Rhop2nylY3IcHmJnk2itn7kOqj1tohCpFEml5pRuSZy4udWywkdtyBAsHWFLF7oiQ=
|
|
29
.vscode/launch.json
vendored
Normal file
29
.vscode/launch.json
vendored
Normal file
@ -0,0 +1,29 @@
|
|||||||
|
{
|
||||||
|
"version": "0.2.0",
|
||||||
|
"configurations": [
|
||||||
|
{
|
||||||
|
"name": "current file",
|
||||||
|
"type": "node",
|
||||||
|
"request": "launch",
|
||||||
|
"args": [
|
||||||
|
"${relativeFile}"
|
||||||
|
],
|
||||||
|
"runtimeArgs": ["-r", "@gitzone/tsrun"],
|
||||||
|
"cwd": "${workspaceRoot}",
|
||||||
|
"protocol": "inspector",
|
||||||
|
"internalConsoleOptions": "openOnSessionStart"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "test.ts",
|
||||||
|
"type": "node",
|
||||||
|
"request": "launch",
|
||||||
|
"args": [
|
||||||
|
"test/test.ts"
|
||||||
|
],
|
||||||
|
"runtimeArgs": ["-r", "@gitzone/tsrun"],
|
||||||
|
"cwd": "${workspaceRoot}",
|
||||||
|
"protocol": "inspector",
|
||||||
|
"internalConsoleOptions": "openOnSessionStart"
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
26
.vscode/settings.json
vendored
Normal file
26
.vscode/settings.json
vendored
Normal file
@ -0,0 +1,26 @@
|
|||||||
|
{
|
||||||
|
"json.schemas": [
|
||||||
|
{
|
||||||
|
"fileMatch": ["/npmextra.json"],
|
||||||
|
"schema": {
|
||||||
|
"type": "object",
|
||||||
|
"properties": {
|
||||||
|
"npmci": {
|
||||||
|
"type": "object",
|
||||||
|
"description": "settings for npmci"
|
||||||
|
},
|
||||||
|
"gitzone": {
|
||||||
|
"type": "object",
|
||||||
|
"description": "settings for gitzone",
|
||||||
|
"properties": {
|
||||||
|
"projectType": {
|
||||||
|
"type": "string",
|
||||||
|
"enum": ["website", "element", "service", "npm"]
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
2
LICENSE
2
LICENSE
@ -1,6 +1,6 @@
|
|||||||
The MIT License (MIT)
|
The MIT License (MIT)
|
||||||
|
|
||||||
Copyright (c) 2015 Push.Rocks
|
Copyright (c) 2015 Lossless GmbH
|
||||||
|
|
||||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||||
of this software and associated documentation files (the "Software"), to deal
|
of this software and associated documentation files (the "Software"), to deal
|
||||||
|
@ -1,6 +0,0 @@
|
|||||||
# smartpath
|
|
||||||
offers smart ways to handle paths
|
|
||||||
|
|
||||||
## Status
|
|
||||||
|
|
||||||
## Documentation
|
|
11
dist/index.js
vendored
11
dist/index.js
vendored
@ -1,11 +0,0 @@
|
|||||||
var SmartpathAbsolute = require("./smartpath.absolute");
|
|
||||||
/**
|
|
||||||
*
|
|
||||||
* @type {{getPath: (function(any): undefined)}}
|
|
||||||
*/
|
|
||||||
var smartpath = {
|
|
||||||
absolute: SmartpathAbsolute
|
|
||||||
};
|
|
||||||
module.exports = smartpath;
|
|
||||||
|
|
||||||
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbImluZGV4LnRzIl0sIm5hbWVzIjpbXSwibWFwcGluZ3MiOiJBQUVBLElBQU8saUJBQWlCLFdBQVcsc0JBQXNCLENBQUMsQ0FBQztBQUczRDs7O0dBR0c7QUFDSCxJQUFJLFNBQVMsR0FBRztJQUNaLFFBQVEsRUFBRSxpQkFBaUI7Q0FDOUIsQ0FBQztBQUdGLGlCQUFTLFNBQVMsQ0FBQyIsImZpbGUiOiJpbmRleC5qcyIsInNvdXJjZXNDb250ZW50IjpbIi8vLyA8cmVmZXJlbmNlIHBhdGg9XCJ0eXBpbmdzL21haW4uZC50c1wiIC8+XG5pbXBvcnQgcGx1Z2lucyA9IHJlcXVpcmUoXCIuL3NtYXJ0cGF0aC5wbHVnaW5zXCIpO1xuaW1wb3J0IFNtYXJ0cGF0aEFic29sdXRlID0gcmVxdWlyZShcIi4vc21hcnRwYXRoLmFic29sdXRlXCIpO1xuXG5cbi8qKlxuICpcbiAqIEB0eXBlIHt7Z2V0UGF0aDogKGZ1bmN0aW9uKGFueSk6IHVuZGVmaW5lZCl9fVxuICovXG5sZXQgc21hcnRwYXRoID0ge1xuICAgIGFic29sdXRlOiBTbWFydHBhdGhBYnNvbHV0ZVxufTtcblxuXG5leHBvcnQgPSBzbWFydHBhdGg7XG4iXSwic291cmNlUm9vdCI6Ii9zb3VyY2UvIn0=
|
|
34
dist/smartpath.absolute.js
vendored
34
dist/smartpath.absolute.js
vendored
@ -1,34 +0,0 @@
|
|||||||
/// <reference path="typings/main.d.ts" />
|
|
||||||
var plugins = require("./smartpath.plugins");
|
|
||||||
var makeAbsolute = function (localPathArg, baseArg) {
|
|
||||||
var absolutePath;
|
|
||||||
if (baseArg) {
|
|
||||||
absolutePath = plugins.path.join(baseArg, localPathArg);
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
absolutePath = plugins.path.resolve(localPathArg);
|
|
||||||
}
|
|
||||||
return absolutePath;
|
|
||||||
};
|
|
||||||
var absolute = function (relativeArg, baseArg) {
|
|
||||||
if (typeof relativeArg === "string") {
|
|
||||||
return makeAbsolute(relativeArg, baseArg);
|
|
||||||
}
|
|
||||||
else if (Array.isArray(relativeArg)) {
|
|
||||||
var relativeArray = relativeArg;
|
|
||||||
var absoluteArray = [];
|
|
||||||
for (var key in relativeArray) {
|
|
||||||
absoluteArray.push(makeAbsolute(relativeArray[key], baseArg));
|
|
||||||
}
|
|
||||||
;
|
|
||||||
return absoluteArray;
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
plugins.beautylog.error("smartpath.absolute() could not make sense of the input. " +
|
|
||||||
"Input is neither String nor Array");
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
};
|
|
||||||
module.exports = absolute;
|
|
||||||
|
|
||||||
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbInNtYXJ0cGF0aC5hYnNvbHV0ZS50cyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiQUFBQSwwQ0FBMEM7QUFDMUMsSUFBTyxPQUFPLFdBQVcscUJBQXFCLENBQUMsQ0FBQztBQUVoRCxJQUFJLFlBQVksR0FBRyxVQUFTLFlBQW1CLEVBQUUsT0FBZTtJQUM1RCxJQUFJLFlBQW1CLENBQUM7SUFDeEIsRUFBRSxDQUFBLENBQUMsT0FBTyxDQUFDLENBQUEsQ0FBQztRQUNSLFlBQVksR0FBRyxPQUFPLENBQUMsSUFBSSxDQUFDLElBQUksQ0FBQyxPQUFPLEVBQUMsWUFBWSxDQUFDLENBQUM7SUFDM0QsQ0FBQztJQUFDLElBQUksQ0FBQyxDQUFDO1FBQ0gsWUFBWSxHQUFHLE9BQU8sQ0FBQyxJQUFJLENBQUMsT0FBTyxDQUFDLFlBQVksQ0FBQyxDQUFDO0lBQ3ZELENBQUM7SUFDRCxNQUFNLENBQUMsWUFBWSxDQUFDO0FBQ3hCLENBQUMsQ0FBQztBQUVGLElBQUksUUFBUSxHQUFHLFVBQVMsV0FBZSxFQUFFLE9BQWU7SUFDcEQsRUFBRSxDQUFBLENBQUMsT0FBTyxXQUFXLEtBQUssUUFBUSxDQUFDLENBQUEsQ0FBQztRQUNoQyxNQUFNLENBQUMsWUFBWSxDQUFDLFdBQVcsRUFBQyxPQUFPLENBQUMsQ0FBQztJQUM3QyxDQUFDO0lBQUMsS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L3NvdXJjZS8ifQ==
|
|
5
dist/smartpath.plugins.js
vendored
5
dist/smartpath.plugins.js
vendored
@ -1,5 +0,0 @@
|
|||||||
/// <reference path="./typings/main.d.ts" />
|
|
||||||
exports.beautylog = require("beautylog");
|
|
||||||
exports.path = require("path");
|
|
||||||
|
|
||||||
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbInNtYXJ0cGF0aC5wbHVnaW5zLnRzIl0sIm5hbWVzIjpbXSwibWFwcGluZ3MiOiJBQUFBLDRDQUE0QztBQUNqQyxpQkFBUyxHQUFHLE9BQU8sQ0FBRSxXQUFXLENBQUMsQ0FBQztBQUNsQyxZQUFJLEdBQUcsT0FBTyxDQUFDLE1BQU0sQ0FBQyxDQUFDIiwiZmlsZSI6InNtYXJ0cGF0aC5wbHVnaW5zLmpzIiwic291cmNlc0NvbnRlbnQiOlsiLy8vIDxyZWZlcmVuY2UgcGF0aD1cIi4vdHlwaW5ncy9tYWluLmQudHNcIiAvPlxuZXhwb3J0IHZhciBiZWF1dHlsb2cgPSByZXF1aXJlIChcImJlYXV0eWxvZ1wiKTtcbmV4cG9ydCB2YXIgcGF0aCA9IHJlcXVpcmUoXCJwYXRoXCIpOyJdLCJzb3VyY2VSb290IjoiL3NvdXJjZS8ifQ==
|
|
19
npmextra.json
Normal file
19
npmextra.json
Normal file
@ -0,0 +1,19 @@
|
|||||||
|
{
|
||||||
|
"npmci": {
|
||||||
|
"npmGlobalTools": [
|
||||||
|
"@gitzone/npmts"
|
||||||
|
],
|
||||||
|
"npmAccessLevel": "public"
|
||||||
|
},
|
||||||
|
"gitzone": {
|
||||||
|
"projectType": "npm",
|
||||||
|
"module": {
|
||||||
|
"githost": "gitlab.com",
|
||||||
|
"gitscope": "pushrocks",
|
||||||
|
"gitrepo": "smartpath",
|
||||||
|
"shortDescription": "offers smart ways to handle paths",
|
||||||
|
"npmPackagename": "@pushrocks/smartpath",
|
||||||
|
"license": "MIT"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -1,4 +0,0 @@
|
|||||||
{
|
|
||||||
"mode": "default",
|
|
||||||
"coveralls": "true"
|
|
||||||
}
|
|
1437
package-lock.json
generated
Normal file
1437
package-lock.json
generated
Normal file
File diff suppressed because it is too large
Load Diff
38
package.json
38
package.json
@ -1,10 +1,13 @@
|
|||||||
{
|
{
|
||||||
"name": "smartpath",
|
"name": "@pushrocks/smartpath",
|
||||||
"version": "2.1.0",
|
"version": "4.0.3",
|
||||||
|
"private": false,
|
||||||
"description": "offers smart ways to handle paths",
|
"description": "offers smart ways to handle paths",
|
||||||
"main": "dist/index.js",
|
"main": "dist_ts/index.js",
|
||||||
|
"typings": "dist_ts/index.d.ts",
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"test": "(npmts)"
|
"test": "(tstest test)",
|
||||||
|
"build": "(tsbuild)"
|
||||||
},
|
},
|
||||||
"repository": {
|
"repository": {
|
||||||
"type": "git",
|
"type": "git",
|
||||||
@ -15,17 +18,30 @@
|
|||||||
"jade",
|
"jade",
|
||||||
"template"
|
"template"
|
||||||
],
|
],
|
||||||
"author": "Smart Coordination GmbH <office@push.rocks> (https://push.rocks)",
|
"author": "Lossless GmbH <office@lossless.com> (https://lossless.com)",
|
||||||
"license": "MIT",
|
"license": "MIT",
|
||||||
"bugs": {
|
"bugs": {
|
||||||
"url": "https://github.com/pushrocks/smartpath/issues"
|
"url": "https://github.com/pushrocks/smartpath/issues"
|
||||||
},
|
},
|
||||||
"homepage": "https://github.com/pushrocks/smartpath",
|
"homepage": "https://github.com/pushrocks/smartpath",
|
||||||
"dependencies": {
|
"dependencies": {},
|
||||||
"beautylog": "^3.1.2"
|
|
||||||
},
|
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"npmts": "^3.3.2",
|
"@gitzone/tsbuild": "^2.1.22",
|
||||||
"should": "^8.2.2"
|
"@gitzone/tsrun": "^1.2.8",
|
||||||
}
|
"@gitzone/tstest": "^1.0.28",
|
||||||
|
"@pushrocks/tapbundle": "^3.2.1",
|
||||||
|
"@types/node": "^13.11.1"
|
||||||
|
},
|
||||||
|
"files": [
|
||||||
|
"ts/**/*",
|
||||||
|
"ts_web/**/*",
|
||||||
|
"dist/**/*",
|
||||||
|
"dist_*/**/*",
|
||||||
|
"dist_ts/**/*",
|
||||||
|
"dist_ts_web/**/*",
|
||||||
|
"assets/**/*",
|
||||||
|
"cli.js",
|
||||||
|
"npmextra.json",
|
||||||
|
"readme.md"
|
||||||
|
]
|
||||||
}
|
}
|
||||||
|
38
readme.md
Normal file
38
readme.md
Normal file
@ -0,0 +1,38 @@
|
|||||||
|
# @pushrocks/smartpath
|
||||||
|
offers smart ways to handle paths
|
||||||
|
|
||||||
|
## Availabililty and Links
|
||||||
|
* [npmjs.org (npm package)](https://www.npmjs.com/package/@pushrocks/smartpath)
|
||||||
|
* [gitlab.com (source)](https://gitlab.com/pushrocks/smartpath)
|
||||||
|
* [github.com (source mirror)](https://github.com/pushrocks/smartpath)
|
||||||
|
* [docs (typedoc)](https://pushrocks.gitlab.io/smartpath/)
|
||||||
|
|
||||||
|
## Status for master
|
||||||
|
[](https://gitlab.com/pushrocks/smartpath/commits/master)
|
||||||
|
[](https://gitlab.com/pushrocks/smartpath/commits/master)
|
||||||
|
[](https://www.npmjs.com/package/@pushrocks/smartpath)
|
||||||
|
[](https://snyk.io/test/npm/@pushrocks/smartpath)
|
||||||
|
[](https://nodejs.org/dist/latest-v10.x/docs/api/)
|
||||||
|
[](https://nodejs.org/dist/latest-v10.x/docs/api/)
|
||||||
|
[](https://prettier.io/)
|
||||||
|
|
||||||
|
## Usage
|
||||||
|
|
||||||
|
Use TypeScript for best in class instellisense.
|
||||||
|
|
||||||
|
For further information read the linked docs at the top of this README.
|
||||||
|
|
||||||
|
> MIT licensed | **©** [Lossless GmbH](https://lossless.gmbh)
|
||||||
|
|
||||||
|
[](https://push.rocks)
|
||||||
|
|
||||||
|
## Contribution
|
||||||
|
|
||||||
|
We are always happy for code contributions. If you are not the code contributing type that is ok. Still, maintaining Open Source repositories takes considerable time and thought. If you like the quality of what we do and our modules are useful to you we would appreciate a little monthly contribution: You can [contribute one time](https://lossless.link/contribute-onetime) or [contribute monthly](https://lossless.link/contribute). :)
|
||||||
|
|
||||||
|
For further information read the linked docs at the top of this readme.
|
||||||
|
|
||||||
|
> MIT licensed | **©** [Lossless GmbH](https://lossless.gmbh)
|
||||||
|
| By using this npm module you agree to our [privacy policy](https://lossless.gmbH/privacy)
|
||||||
|
|
||||||
|
[](https://maintainedby.lossless.com)
|
26
test/test.js
26
test/test.js
@ -1,26 +0,0 @@
|
|||||||
/// <reference path="../ts/typings/main.d.ts" />
|
|
||||||
var should = require("should");
|
|
||||||
var smartpath = require("../dist/index.js");
|
|
||||||
describe("smartpath", function () {
|
|
||||||
describe("absolute()", function () {
|
|
||||||
var baseString = "/basedir";
|
|
||||||
var relativeString = "somedir/somefile.txt";
|
|
||||||
var relativeString2 = "anotherdir/anotherfile.txt";
|
|
||||||
var relativeArray = [relativeString, relativeString, relativeString2];
|
|
||||||
it("should make a string absolute", function () {
|
|
||||||
smartpath.absolute(relativeString).should.startWith("/");
|
|
||||||
smartpath.absolute(relativeString).should.endWith(relativeString);
|
|
||||||
smartpath.absolute(relativeString, baseString).should.equal("/basedir/somedir/somefile.txt");
|
|
||||||
});
|
|
||||||
it("should make an array of relative Strings an Array of absolute Strings", function () {
|
|
||||||
var absoluteArray = smartpath.absolute(relativeArray);
|
|
||||||
absoluteArray[2].should.startWith("/");
|
|
||||||
absoluteArray[2].should.endWith(relativeString2);
|
|
||||||
});
|
|
||||||
it("should return false if neither String nor Array", function () {
|
|
||||||
smartpath.absolute(3).should.be.false();
|
|
||||||
});
|
|
||||||
});
|
|
||||||
});
|
|
||||||
|
|
||||||
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbInRlc3QudHMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6IkFBQUEsZ0R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RXaXRoKFwiL1wiKTtcbiAgICAgICAgICAgIHNtYXJ0cGF0aC5hYnNvbHV0ZShyZWxhdGl2ZVN0cmluZykuc2hvdWxkLmVuZFdpdGgocmVsYXRpdmVTdHJpbmcpO1xuICAgICAgICAgICAgc21hcnRwYXRoLmFic29sdXRlKHJlbGF0aXZlU3RyaW5nLGJhc2VTdHJpbmcpLnNob3VsZC5lcXVhbChcIi9iYXNlZGlyL3NvbWVkaXIvc29tZWZpbGUudHh0XCIpO1xuICAgICAgICB9KTtcbiAgICAgICAgaXQoXCJzaG91bGQgbWFrZSBhbiBhcnJheSBvZiByZWxhdGl2ZSBTdHJpbmdzIGFuIEFycmF5IG9mIGFic29sdXRlIFN0cmluZ3NcIixmdW5jdGlvbigpe1xuICAgICAgICAgICAgbGV0IGFic29sdXRlQXJyYXkgPSBzbWFydHBhdGguYWJzb2x1dGUocmVsYXRpdmVBcnJheSk7XG4gICAgICAgICAgICBhYnNvbHV0ZUFycmF5WzJdLnNob3VsZC5zdGFydFdpdGgoXCIvXCIpO1xuICAgICAgICAgICAgYWJzb2x1dGVBcnJheVsyXS5zaG91bGQuZW5kV2l0aChyZWxhdGl2ZVN0cmluZzIpO1xuXG4gICAgICAgIH0pXG4gICAgICAgIGl0KFwic2hvdWxkIHJldHVybiBmYWxzZSBpZiBuZWl0aGVyIFN0cmluZyBub3IgQXJyYXlcIixmdW5jdGlvbigpe1xuICAgICAgICAgICAgc21hcnRwYXRoLmFic29sdXRlKDMpLnNob3VsZC5iZS5mYWxzZSgpO1xuICAgICAgICB9KTtcbiAgICB9KVxufSk7XG4iXSwic291cmNlUm9vdCI6Ii9zb3VyY2UvIn0=
|
|
@ -1 +0,0 @@
|
|||||||
{"version":3,"file":"test.js","sourceRoot":"","sources":["test.ts"],"names":[],"mappings":"AAAA,gDAAgD;AAChD,IAAI,MAAM,GAAG,OAAO,CAAC,QAAQ,CAAC,CAAC;AAC/B,IAAI,SAAS,GAAG,OAAO,CAAC,kBAAkB,CAAC,CAAC;AAE5C,QAAQ,CAAC,WAAW,EAAC;IACjB,QAAQ,CAAC,YAAY,EAAC;QAClB,IAAI,UAAU,GAAG,UAAU,CAAA;QAC3B,IAAI,cAAc,GAAG,sBAAsB,CAAC;QAC5C,IAAI,eAAe,GAAG,4BAA4B,CAAC;QACnD,IAAI,aAAa,GAAG,CAAC,cAAc,EAAC,cAAc,EAAC,eAAe,CAAC,CAAC;QACpE,EAAE,CAAC,+BAA+B,EAAC;YAC/B,SAAS,CAAC,QAAQ,CAAC,cAAc,CAAC,CAAC,MAAM,CAAC,SAAS,CAAC,GAAG,CAAC,CAAC;YACzD,SAAS,CAAC,QAAQ,CAAC,cAAc,CAAC,CAAC,MAAM,CAAC,OAAO,CAAC,cAAc,CAAC,CAAC;YAClE,SAAS,CAAC,QAAQ,CAAC,cAAc,EAAC,UAAU,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,+BAA+B,CAAC,CAAC;QAChG,CAAC,CAAC,CAAC;QACH,EAAE,CAAC,uEAAuE,EAAC;YACvE,IAAI,aAAa,GAAG,SAAS,CAAC,QAAQ,CAAC,aAAa,CAAC,CAAC;YACtD,aAAa,CAAC,CAAC,CAAC,CAAC,MAAM,CAAC,SAAS,CAAC,GAAG,CAAC,CAAC;YACvC,aAAa,CAAC,CAAC,CAAC,CAAC,MAAM,CAAC,OAAO,CAAC,eAAe,CAAC,CAAC;QAErD,CAAC,CAAC,CAAA;QACF,EAAE,CAAC,iDAAiD,EAAC;YACjD,SAAS,CAAC,QAAQ,CAAC,CAAC,CAAC,CAAC,MAAM,CAAC,EAAE,CAAC,KAAK,EAAE,CAAC;QAC5C,CAAC,CAAC,CAAC;IACP,CAAC,CAAC,CAAA;AACN,CAAC,CAAC,CAAC"}
|
|
88
test/test.ts
88
test/test.ts
@ -1,26 +1,66 @@
|
|||||||
/// <reference path="../ts/typings/main.d.ts" />
|
import { tap, expect } from '@pushrocks/tapbundle';
|
||||||
let should = require("should");
|
import * as smartpath from '../ts/index';
|
||||||
let smartpath = require("../dist/index.js");
|
|
||||||
|
|
||||||
describe("smartpath",function(){
|
let mySmartpath: smartpath.Smartpath;
|
||||||
describe("absolute()",function(){
|
tap.test('expect create a valid instance', async () => {
|
||||||
let baseString = "/basedir"
|
mySmartpath = new smartpath.Smartpath('/some/path/to/some.file');
|
||||||
let relativeString = "somedir/somefile.txt";
|
expect(mySmartpath).to.be.instanceof(smartpath.Smartpath);
|
||||||
let relativeString2 = "anotherdir/anotherfile.txt";
|
expect(mySmartpath.pathLevelsBackwards).to.be.of.length(5);
|
||||||
let relativeArray = [relativeString,relativeString,relativeString2];
|
|
||||||
it("should make a string absolute",function(){
|
|
||||||
smartpath.absolute(relativeString).should.startWith("/");
|
|
||||||
smartpath.absolute(relativeString).should.endWith(relativeString);
|
|
||||||
smartpath.absolute(relativeString,baseString).should.equal("/basedir/somedir/somefile.txt");
|
|
||||||
});
|
|
||||||
it("should make an array of relative Strings an Array of absolute Strings",function(){
|
|
||||||
let absoluteArray = smartpath.absolute(relativeArray);
|
|
||||||
absoluteArray[2].should.startWith("/");
|
|
||||||
absoluteArray[2].should.endWith(relativeString2);
|
|
||||||
|
|
||||||
})
|
|
||||||
it("should return false if neither String nor Array",function(){
|
|
||||||
smartpath.absolute(3).should.be.false();
|
|
||||||
});
|
|
||||||
})
|
|
||||||
});
|
});
|
||||||
|
|
||||||
|
let filePathString = './somedir/somefile.json';
|
||||||
|
let dirPathString = './somedir/anotherdir';
|
||||||
|
let dirPathString2 = './somedir/another.dir/';
|
||||||
|
|
||||||
|
tap.test('expect be true for a file path', async () => {
|
||||||
|
expect(smartpath.check.isFile(filePathString)).to.be.true;
|
||||||
|
});
|
||||||
|
tap.test('expect be false for a directory path', async () => {
|
||||||
|
expect(smartpath.check.isFile(dirPathString)).to.be.false;
|
||||||
|
expect(smartpath.check.isFile(dirPathString2)).to.be.false;
|
||||||
|
});
|
||||||
|
|
||||||
|
tap.test('expect be true for a directory path', async () => {
|
||||||
|
expect(smartpath.check.isDir(dirPathString)).to.be.true;
|
||||||
|
|
||||||
|
expect(smartpath.check.isDir(dirPathString2)).to.be.true;
|
||||||
|
});
|
||||||
|
|
||||||
|
tap.test('expect be false for a file path', async () => {
|
||||||
|
expect(smartpath.check.isDir(filePathString)).to.be.false;
|
||||||
|
});
|
||||||
|
|
||||||
|
let baseString = '/basedir';
|
||||||
|
let relativeString = 'somedir/somefile.txt';
|
||||||
|
let relativeString2 = 'anotherdir/anotherfile.txt';
|
||||||
|
let relativeArray = [relativeString, relativeString, relativeString2];
|
||||||
|
tap.test('expect make a string absolute', async () => {
|
||||||
|
expect(smartpath.transform.toAbsolute(relativeString)).startWith('/');
|
||||||
|
expect(smartpath.transform.toAbsolute(relativeString)).endWith(relativeString);
|
||||||
|
expect(smartpath.transform.toAbsolute(relativeString, baseString)).equal(
|
||||||
|
'/basedir/somedir/somefile.txt'
|
||||||
|
);
|
||||||
|
});
|
||||||
|
tap.test('expect make an array of relative Strings an Array of absolute Strings', async () => {
|
||||||
|
let absoluteArray = smartpath.transform.toAbsolute(relativeArray, baseString);
|
||||||
|
expect(absoluteArray[2]).to.startWith('/');
|
||||||
|
expect(absoluteArray[2]).endWith(relativeString2);
|
||||||
|
});
|
||||||
|
|
||||||
|
tap.test("expect return 'url' for an URL", async () => {
|
||||||
|
expect(smartpath.get.type('https://push.rocks/some/url')).equal('url');
|
||||||
|
expect(smartpath.get.type('https://push.rocks/some/url')).not.equal('local');
|
||||||
|
});
|
||||||
|
tap.test("expect return 'path' for a Path", async () => {
|
||||||
|
expect(smartpath.get.type('/some/absolute/path/')).equal('local');
|
||||||
|
expect(smartpath.get.type('./some/relative/path/')).not.equal('url');
|
||||||
|
});
|
||||||
|
|
||||||
|
tap.test('expect a absolute path for an home relative URL', async () => {
|
||||||
|
console.log(smartpath.get.home('~/test'));
|
||||||
|
});
|
||||||
|
tap.test('expect return the home directory path when no argument is specified', async () => {
|
||||||
|
console.log(smartpath.get.home());
|
||||||
|
});
|
||||||
|
|
||||||
|
tap.start();
|
||||||
|
19
ts/index.ts
19
ts/index.ts
@ -1,15 +1,8 @@
|
|||||||
/// <reference path="typings/main.d.ts" />
|
// import modules
|
||||||
import plugins = require("./smartpath.plugins");
|
import * as check from './smartpath.check';
|
||||||
import SmartpathAbsolute = require("./smartpath.absolute");
|
import * as get from './smartpath.get';
|
||||||
|
import * as transform from './smartpath.transform';
|
||||||
|
|
||||||
|
export { check, get, transform };
|
||||||
|
|
||||||
/**
|
export * from './smartpath.classes.smartpath';
|
||||||
*
|
|
||||||
* @type {{getPath: (function(any): undefined)}}
|
|
||||||
*/
|
|
||||||
let smartpath = {
|
|
||||||
absolute: SmartpathAbsolute
|
|
||||||
};
|
|
||||||
|
|
||||||
|
|
||||||
export = smartpath;
|
|
||||||
|
@ -1,31 +0,0 @@
|
|||||||
/// <reference path="typings/main.d.ts" />
|
|
||||||
import plugins = require("./smartpath.plugins");
|
|
||||||
|
|
||||||
var makeAbsolute = function(localPathArg:string, baseArg?:string):string {
|
|
||||||
let absolutePath:string;
|
|
||||||
if(baseArg){
|
|
||||||
absolutePath = plugins.path.join(baseArg,localPathArg);
|
|
||||||
} else {
|
|
||||||
absolutePath = plugins.path.resolve(localPathArg);
|
|
||||||
}
|
|
||||||
return absolutePath;
|
|
||||||
};
|
|
||||||
|
|
||||||
var absolute = function(relativeArg:any, baseArg?:string):any {
|
|
||||||
if(typeof relativeArg === "string"){
|
|
||||||
return makeAbsolute(relativeArg,baseArg);
|
|
||||||
} else if(Array.isArray(relativeArg)){
|
|
||||||
let relativeArray = relativeArg
|
|
||||||
let absoluteArray:string[] = [];
|
|
||||||
for (let key in relativeArray){
|
|
||||||
absoluteArray.push(makeAbsolute(relativeArray[key],baseArg));
|
|
||||||
};
|
|
||||||
return absoluteArray;
|
|
||||||
} else {
|
|
||||||
plugins.beautylog.error("smartpath.absolute() could not make sense of the input. " +
|
|
||||||
"Input is neither String nor Array");
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
export = absolute;
|
|
9
ts/smartpath.check.ts
Normal file
9
ts/smartpath.check.ts
Normal file
@ -0,0 +1,9 @@
|
|||||||
|
import plugins = require('./smartpath.plugins');
|
||||||
|
|
||||||
|
export let isDir = function(pathArg: string) {
|
||||||
|
return !isFile(pathArg);
|
||||||
|
};
|
||||||
|
|
||||||
|
export let isFile = function(pathArg) {
|
||||||
|
return /\.[a-zA-Z]*$/.test(pathArg); // checks if there is a .anything at the end
|
||||||
|
};
|
15
ts/smartpath.classes.smartpath.ts
Normal file
15
ts/smartpath.classes.smartpath.ts
Normal file
@ -0,0 +1,15 @@
|
|||||||
|
import * as plugins from './smartpath.plugins';
|
||||||
|
import * as getMod from './smartpath.get';
|
||||||
|
|
||||||
|
export class Smartpath {
|
||||||
|
originalPath: string;
|
||||||
|
type: getMod.TPathType;
|
||||||
|
pathLevels: string[];
|
||||||
|
pathLevelsBackwards: string[];
|
||||||
|
constructor(pathArg: string) {
|
||||||
|
this.originalPath = pathArg;
|
||||||
|
this.type = getMod.type(this.originalPath);
|
||||||
|
this.pathLevels = getMod.pathLevels(this.originalPath);
|
||||||
|
this.pathLevelsBackwards = getMod.pathLevelsBackwards(this.originalPath);
|
||||||
|
}
|
||||||
|
}
|
36
ts/smartpath.get.ts
Normal file
36
ts/smartpath.get.ts
Normal file
@ -0,0 +1,36 @@
|
|||||||
|
import plugins = require('./smartpath.plugins');
|
||||||
|
export type TPathType = 'url' | 'local';
|
||||||
|
|
||||||
|
/**
|
||||||
|
* returns the type of the given path. Can be "url" or "local"
|
||||||
|
*/
|
||||||
|
export let type = function(pathStringArg: string): TPathType {
|
||||||
|
let urlRegex = /http[s|\s]:\/\/.*/i;
|
||||||
|
if (urlRegex.exec(pathStringArg)) {
|
||||||
|
return 'url';
|
||||||
|
} else {
|
||||||
|
return 'local';
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
export let home = function(pathArgument?: string) {
|
||||||
|
if (pathArgument) {
|
||||||
|
return pathArgument.replace('~', plugins.os.homedir());
|
||||||
|
} else {
|
||||||
|
return plugins.os.homedir();
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
export type TSystemArg = 'dynamic' | 'windows' | 'linux' | 'osx';
|
||||||
|
|
||||||
|
export let pathLevels = (pathArg: string, systemArg: TSystemArg = 'dynamic') => {
|
||||||
|
let pathLevelArray: string[];
|
||||||
|
if (systemArg === 'dynamic') {
|
||||||
|
pathLevelArray = pathArg.split(plugins.path.sep);
|
||||||
|
}
|
||||||
|
return pathLevelArray;
|
||||||
|
};
|
||||||
|
|
||||||
|
export let pathLevelsBackwards = (pathArg: string, systemArg?: TSystemArg) => {
|
||||||
|
return pathLevels(pathArg, systemArg).reverse();
|
||||||
|
};
|
@ -1,3 +1,4 @@
|
|||||||
/// <reference path="./typings/main.d.ts" />
|
import * as os from 'os';
|
||||||
export var beautylog = require ("beautylog");
|
import * as path from 'path';
|
||||||
export var path = require("path");
|
|
||||||
|
export { os, path };
|
||||||
|
41
ts/smartpath.transform.ts
Normal file
41
ts/smartpath.transform.ts
Normal file
@ -0,0 +1,41 @@
|
|||||||
|
import plugins = require('./smartpath.plugins');
|
||||||
|
|
||||||
|
/* ------------------------------------------ *
|
||||||
|
* ------------ helpers --------------------- *
|
||||||
|
* ------------------------------------------ */
|
||||||
|
|
||||||
|
// checks a file
|
||||||
|
let makeAbsolute = function(localPathArg: string, baseArg?: string): string {
|
||||||
|
let absolutePath: string;
|
||||||
|
let alreadyAbsolute = plugins.path.isAbsolute(localPathArg);
|
||||||
|
if (baseArg && !alreadyAbsolute) {
|
||||||
|
absolutePath = plugins.path.join(baseArg, localPathArg);
|
||||||
|
} else if (!alreadyAbsolute) {
|
||||||
|
absolutePath = plugins.path.resolve(localPathArg);
|
||||||
|
} else {
|
||||||
|
absolutePath = localPathArg;
|
||||||
|
}
|
||||||
|
return absolutePath;
|
||||||
|
};
|
||||||
|
|
||||||
|
/* ------------------------------------------ *
|
||||||
|
* ------- export functions ----------------- *
|
||||||
|
* ------------------------------------------ */
|
||||||
|
export let toAbsolute = function(relativeArg: string | string[], baseArg?: string): any {
|
||||||
|
if (typeof relativeArg === 'string') {
|
||||||
|
return makeAbsolute(relativeArg, baseArg);
|
||||||
|
} else if (Array.isArray(relativeArg)) {
|
||||||
|
let relativeArray = relativeArg;
|
||||||
|
let absoluteArray: string[] = [];
|
||||||
|
for (let key in relativeArray) {
|
||||||
|
absoluteArray.push(makeAbsolute(relativeArray[key], baseArg));
|
||||||
|
}
|
||||||
|
return absoluteArray;
|
||||||
|
} else {
|
||||||
|
console.error(
|
||||||
|
'smartpath.absolute() could not make sense of the input. ' +
|
||||||
|
'Input is neither String nor Array'
|
||||||
|
);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
};
|
@ -1,6 +0,0 @@
|
|||||||
{
|
|
||||||
"ambientDependencies": {
|
|
||||||
"mocha": "github:DefinitelyTyped/DefinitelyTyped/mocha/mocha.d.ts#d6dd320291705694ba8e1a79497a908e9f5e6617",
|
|
||||||
"node": "github:DefinitelyTyped/DefinitelyTyped/node/node.d.ts#efa0c1196d7280640e624ac1e7fa604502e7bd63"
|
|
||||||
}
|
|
||||||
}
|
|
17
tslint.json
Normal file
17
tslint.json
Normal file
@ -0,0 +1,17 @@
|
|||||||
|
{
|
||||||
|
"extends": ["tslint:latest", "tslint-config-prettier"],
|
||||||
|
"rules": {
|
||||||
|
"semicolon": [true, "always"],
|
||||||
|
"no-console": false,
|
||||||
|
"ordered-imports": false,
|
||||||
|
"object-literal-sort-keys": false,
|
||||||
|
"member-ordering": {
|
||||||
|
"options":{
|
||||||
|
"order": [
|
||||||
|
"static-method"
|
||||||
|
]
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"defaultSeverity": "warning"
|
||||||
|
}
|
Reference in New Issue
Block a user