Compare commits
69 Commits
Author | SHA1 | Date | |
---|---|---|---|
e3f6c0a8a1 | |||
db7dc635f1 | |||
8bb10f45b3 | |||
68ccb0e708 | |||
fc51d498c7 | |||
6474016fc1 | |||
ea42dbd1c3 | |||
9e8ce8215c | |||
b02ab97d4f | |||
ecfefc250c | |||
dde9948404 | |||
d041d8de68 | |||
f03b3df55b | |||
ca387124ee | |||
027b3fe9ad | |||
1b4681c065 | |||
96168fd870 | |||
e81c37e60a | |||
87454d41da | |||
97ae2d87b1 | |||
e23624a93f | |||
7183fcc00a | |||
9fad6100f0 | |||
d0e3065d12 | |||
5245e50f3d | |||
00bb39b8fe | |||
ddfae30a18 | |||
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 |
66
.gitea/workflows/default_nottags.yaml
Normal file
66
.gitea/workflows/default_nottags.yaml
Normal file
@ -0,0 +1,66 @@
|
||||
name: Default (not tags)
|
||||
|
||||
on:
|
||||
push:
|
||||
tags-ignore:
|
||||
- '**'
|
||||
|
||||
env:
|
||||
IMAGE: registry.gitlab.com/hosttoday/ht-docker-node:npmci
|
||||
NPMCI_COMPUTED_REPOURL: https://${{gitea.repository_owner}}:${{secrets.GITEA_TOKEN}}@gitea.lossless.digital/${{gitea.repository}}.git
|
||||
NPMCI_TOKEN_NPM: ${{secrets.NPMCI_TOKEN_NPM}}
|
||||
NPMCI_TOKEN_NPM2: ${{secrets.NPMCI_TOKEN_NPM2}}
|
||||
NPMCI_GIT_GITHUBTOKEN: ${{secrets.NPMCI_GIT_GITHUBTOKEN}}
|
||||
NPMCI_URL_CLOUDLY: ${{secrets.NPMCI_URL_CLOUDLY}}
|
||||
|
||||
jobs:
|
||||
security:
|
||||
runs-on: ubuntu-latest
|
||||
continue-on-error: true
|
||||
container:
|
||||
image: ${{ env.IMAGE }}
|
||||
|
||||
steps:
|
||||
- uses: actions/checkout@v3
|
||||
|
||||
- name: Install pnpm and npmci
|
||||
run: |
|
||||
pnpm install -g pnpm
|
||||
pnpm install -g @shipzone/npmci
|
||||
|
||||
- name: Run npm prepare
|
||||
run: npmci npm prepare
|
||||
|
||||
- name: Audit production dependencies
|
||||
run: |
|
||||
npmci command npm config set registry https://registry.npmjs.org
|
||||
npmci command pnpm audit --audit-level=high --prod
|
||||
continue-on-error: true
|
||||
|
||||
- name: Audit development dependencies
|
||||
run: |
|
||||
npmci command npm config set registry https://registry.npmjs.org
|
||||
npmci command pnpm audit --audit-level=high --dev
|
||||
continue-on-error: true
|
||||
|
||||
test:
|
||||
if: ${{ always() }}
|
||||
needs: security
|
||||
runs-on: ubuntu-latest
|
||||
container:
|
||||
image: ${{ env.IMAGE }}
|
||||
|
||||
steps:
|
||||
- uses: actions/checkout@v3
|
||||
|
||||
- name: Test stable
|
||||
run: |
|
||||
npmci node install stable
|
||||
npmci npm install
|
||||
npmci npm test
|
||||
|
||||
- name: Test build
|
||||
run: |
|
||||
npmci node install stable
|
||||
npmci npm install
|
||||
npmci npm build
|
124
.gitea/workflows/default_tags.yaml
Normal file
124
.gitea/workflows/default_tags.yaml
Normal file
@ -0,0 +1,124 @@
|
||||
name: Default (tags)
|
||||
|
||||
on:
|
||||
push:
|
||||
tags:
|
||||
- '*'
|
||||
|
||||
env:
|
||||
IMAGE: registry.gitlab.com/hosttoday/ht-docker-node:npmci
|
||||
NPMCI_COMPUTED_REPOURL: https://${{gitea.repository_owner}}:${{secrets.GITEA_TOKEN}}@gitea.lossless.digital/${{gitea.repository}}.git
|
||||
NPMCI_TOKEN_NPM: ${{secrets.NPMCI_TOKEN_NPM}}
|
||||
NPMCI_TOKEN_NPM2: ${{secrets.NPMCI_TOKEN_NPM2}}
|
||||
NPMCI_GIT_GITHUBTOKEN: ${{secrets.NPMCI_GIT_GITHUBTOKEN}}
|
||||
NPMCI_URL_CLOUDLY: ${{secrets.NPMCI_URL_CLOUDLY}}
|
||||
|
||||
jobs:
|
||||
security:
|
||||
runs-on: ubuntu-latest
|
||||
continue-on-error: true
|
||||
container:
|
||||
image: ${{ env.IMAGE }}
|
||||
|
||||
steps:
|
||||
- uses: actions/checkout@v3
|
||||
|
||||
- name: Prepare
|
||||
run: |
|
||||
pnpm install -g pnpm
|
||||
pnpm install -g @shipzone/npmci
|
||||
npmci npm prepare
|
||||
|
||||
- name: Audit production dependencies
|
||||
run: |
|
||||
npmci command npm config set registry https://registry.npmjs.org
|
||||
npmci command pnpm audit --audit-level=high --prod
|
||||
continue-on-error: true
|
||||
|
||||
- name: Audit development dependencies
|
||||
run: |
|
||||
npmci command npm config set registry https://registry.npmjs.org
|
||||
npmci command pnpm audit --audit-level=high --dev
|
||||
continue-on-error: true
|
||||
|
||||
test:
|
||||
if: ${{ always() }}
|
||||
needs: security
|
||||
runs-on: ubuntu-latest
|
||||
container:
|
||||
image: ${{ env.IMAGE }}
|
||||
|
||||
steps:
|
||||
- uses: actions/checkout@v3
|
||||
|
||||
- name: Prepare
|
||||
run: |
|
||||
pnpm install -g pnpm
|
||||
pnpm install -g @shipzone/npmci
|
||||
npmci npm prepare
|
||||
|
||||
- name: Test stable
|
||||
run: |
|
||||
npmci node install stable
|
||||
npmci npm install
|
||||
npmci npm test
|
||||
|
||||
- name: Test build
|
||||
run: |
|
||||
npmci node install stable
|
||||
npmci npm install
|
||||
npmci npm build
|
||||
|
||||
release:
|
||||
needs: test
|
||||
if: github.event_name == 'push' && startsWith(github.ref, 'refs/tags/')
|
||||
runs-on: ubuntu-latest
|
||||
container:
|
||||
image: ${{ env.IMAGE }}
|
||||
|
||||
steps:
|
||||
- uses: actions/checkout@v3
|
||||
|
||||
- name: Prepare
|
||||
run: |
|
||||
pnpm install -g pnpm
|
||||
pnpm install -g @shipzone/npmci
|
||||
npmci npm prepare
|
||||
|
||||
- name: Release
|
||||
run: |
|
||||
npmci node install stable
|
||||
npmci npm publish
|
||||
|
||||
metadata:
|
||||
needs: test
|
||||
if: github.event_name == 'push' && startsWith(github.ref, 'refs/tags/')
|
||||
runs-on: ubuntu-latest
|
||||
container:
|
||||
image: ${{ env.IMAGE }}
|
||||
continue-on-error: true
|
||||
|
||||
steps:
|
||||
- uses: actions/checkout@v3
|
||||
|
||||
- name: Prepare
|
||||
run: |
|
||||
pnpm install -g pnpm
|
||||
pnpm install -g @shipzone/npmci
|
||||
npmci npm prepare
|
||||
|
||||
- name: Code quality
|
||||
run: |
|
||||
npmci command npm install -g typescript
|
||||
npmci npm install
|
||||
|
||||
- name: Trigger
|
||||
run: npmci trigger
|
||||
|
||||
- name: Build docs and upload artifacts
|
||||
run: |
|
||||
npmci node install stable
|
||||
npmci npm install
|
||||
pnpm install -g @gitzone/tsdoc
|
||||
npmci command tsdoc
|
||||
continue-on-error: true
|
26
.gitignore
vendored
26
.gitignore
vendored
@ -1,8 +1,20 @@
|
||||
node_modules/
|
||||
.settings/
|
||||
.idea/
|
||||
docs/
|
||||
ts/typings/
|
||||
ts/**/*.js
|
||||
ts/**/*.js.map
|
||||
.nogit/
|
||||
|
||||
# artifacts
|
||||
coverage/
|
||||
public/
|
||||
pages/
|
||||
|
||||
# installs
|
||||
node_modules/
|
||||
|
||||
# caches
|
||||
.yarn/
|
||||
.cache/
|
||||
.rpt2_cache
|
||||
|
||||
# builds
|
||||
dist/
|
||||
dist_*/
|
||||
|
||||
# custom
|
141
.gitlab-ci.yml
Normal file
141
.gitlab-ci.yml
Normal file
@ -0,0 +1,141 @@
|
||||
# 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
|
||||
|
||||
before_script:
|
||||
- npm install -g @shipzone/npmci
|
||||
|
||||
# ====================
|
||||
# security stage
|
||||
# ====================
|
||||
mirror:
|
||||
stage: security
|
||||
script:
|
||||
- npmci git mirror
|
||||
only:
|
||||
- tags
|
||||
tags:
|
||||
- lossless
|
||||
- docker
|
||||
- notpriv
|
||||
|
||||
auditProductionDependencies:
|
||||
image: registry.gitlab.com/hosttoday/ht-docker-node:npmci
|
||||
stage: security
|
||||
script:
|
||||
- npmci npm prepare
|
||||
- npmci command npm install --production --ignore-scripts
|
||||
- npmci command npm config set registry https://registry.npmjs.org
|
||||
- npmci command npm audit --audit-level=high --only=prod --production
|
||||
tags:
|
||||
- docker
|
||||
allow_failure: true
|
||||
|
||||
auditDevDependencies:
|
||||
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 --only=dev
|
||||
tags:
|
||||
- docker
|
||||
allow_failure: true
|
||||
|
||||
# ====================
|
||||
# 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:
|
||||
- docker
|
||||
|
||||
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:
|
||||
- docker
|
||||
|
||||
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
|
||||
only:
|
||||
- tags
|
||||
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 stable
|
||||
- npmci npm prepare
|
||||
- npmci command npm install -g @gitzone/tsdoc
|
||||
- npmci npm install
|
||||
- npmci command tsdoc
|
||||
tags:
|
||||
- lossless
|
||||
- docker
|
||||
- notpriv
|
||||
only:
|
||||
- tags
|
||||
artifacts:
|
||||
expire_in: 1 week
|
||||
paths:
|
||||
- public
|
||||
allow_failure: true
|
15
.travis.yml
15
.travis.yml
@ -1,15 +0,0 @@
|
||||
language: node_js
|
||||
node_js:
|
||||
- 4.3.1
|
||||
- stable
|
||||
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=
|
11
.vscode/launch.json
vendored
Normal file
11
.vscode/launch.json
vendored
Normal file
@ -0,0 +1,11 @@
|
||||
{
|
||||
"version": "0.2.0",
|
||||
"configurations": [
|
||||
{
|
||||
"command": "npm test",
|
||||
"name": "Run npm test",
|
||||
"request": "launch",
|
||||
"type": "node-terminal"
|
||||
}
|
||||
]
|
||||
}
|
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", "wcc"]
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
@ -1,6 +0,0 @@
|
||||
# smartpath
|
||||
offers smart ways to handle paths
|
||||
|
||||
## Status
|
||||
|
||||
## Documentation
|
13
dist/index.js
vendored
13
dist/index.js
vendored
@ -1,13 +0,0 @@
|
||||
var SmartpathTransform = require("./smartpath.transform");
|
||||
var SmartpathGet = require("./smartpath.get");
|
||||
/**
|
||||
*
|
||||
* @type {{getPath: (function(any): undefined)}}
|
||||
*/
|
||||
var smartpath = {
|
||||
transform: SmartpathTransform,
|
||||
get: SmartpathGet
|
||||
};
|
||||
module.exports = smartpath;
|
||||
|
||||
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbImluZGV4LnRzIl0sIm5hbWVzIjpbXSwibWFwcGluZ3MiOiJBQUVBLElBQU8sa0JBQWtCLFdBQVcsdUJBQXVCLENBQUMsQ0FBQztBQUM3RCxJQUFPLFlBQVksV0FBVyxpQkFBaUIsQ0FBQyxDQUFDO0FBRWpEOzs7R0FHRztBQUNILElBQUksU0FBUyxHQUFHO0lBQ1osU0FBUyxFQUFFLGtCQUFrQjtJQUM3QixHQUFHLEVBQUUsWUFBWTtDQUVwQixDQUFDO0FBR0YsaUJBQVMsU0FBUyxDQUFDIiwiZmlsZSI6ImluZGV4LmpzIiwic291cmNlc0NvbnRlbnQiOlsiLy8vIDxyZWZlcmVuY2UgcGF0aD1cInR5cGluZ3MvbWFpbi5kLnRzXCIgLz5cbmltcG9ydCBwbHVnaW5zID0gcmVxdWlyZShcIi4vc21hcnRwYXRoLnBsdWdpbnNcIik7XG5pbXBvcnQgU21hcnRwYXRoVHJhbnNmb3JtID0gcmVxdWlyZShcIi4vc21hcnRwYXRoLnRyYW5zZm9ybVwiKTtcbmltcG9ydCBTbWFydHBhdGhHZXQgPSByZXF1aXJlKFwiLi9zbWFydHBhdGguZ2V0XCIpO1xuXG4vKipcbiAqXG4gKiBAdHlwZSB7e2dldFBhdGg6IChmdW5jdGlvbihhbnkpOiB1bmRlZmluZWQpfX1cbiAqL1xubGV0IHNtYXJ0cGF0aCA9IHtcbiAgICB0cmFuc2Zvcm06IFNtYXJ0cGF0aFRyYW5zZm9ybSxcbiAgICBnZXQ6IFNtYXJ0cGF0aEdldFxuXG59O1xuXG5cbmV4cG9ydCA9IHNtYXJ0cGF0aDtcbiJdLCJzb3VyY2VSb290IjoiL3NvdXJjZS8ifQ==
|
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,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbInNtYXJ0cGF0aC5hYnNvbHV0ZS50cyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiQUFBQSwwQ0FBMEM7QUFDMUMsSUFBTyxPQUFPLFdBQVcscUJBQXFCLENBQUMsQ0FBQztBQUVoRCxJQUFJLFlBQVksR0FBRyxVQUFTLFlBQW1CLEVBQUUsT0FBZTtJQUM1RCxJQUFJLFlBQW1CLENBQUM7SUFDeEIsRUFBRSxDQUFBLENBQUMsT0FBTyxDQUFDLENBQUEsQ0FBQztRQUNSLFlBQVksR0FBRyxPQUFPLENBQUMsSUFBSSxDQUFDLElBQUksQ0FBQyxPQUFPLEVBQUMsWUFBWSxDQUFDLENBQUM7SUFDM0QsQ0FBQztJQUFDLElBQUksQ0FBQyxDQUFDO1FBQ0gsWUFBWSxHQUFHLE9BQU8sQ0FBQyxJQUFJLENBQUMsT0FBTyxDQUFDLF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V0ZUFycmF5O1xuICAgIH0gZWxzZSB7XG4gICAgICAgIHBsdWdpbnMuYmVhdXR5bG9nLmVycm9yKFwic21hcnRwYXRoLmFic29sdXRlKCkgY291bGQgbm90IG1ha2Ugc2Vuc2Ugb2YgdGhlIGlucHV0LiBcIiArXG4gICAgICAgICAgICBcIklucHV0IGlzIG5laXRoZXIgU3RyaW5nIG5vciBBcnJheVwiKTtcbiAgICAgICAgcmV0dXJuIGZhbHNlO1xuICAgIH1cbn07XG5cbmV4cG9ydCA9IGFic29sdXRlOyJdLCJzb3VyY2VSb290IjoiL3NvdXJjZS8ifQ==
|
12
dist/smartpath.get.js
vendored
12
dist/smartpath.get.js
vendored
@ -1,12 +0,0 @@
|
||||
exports.type = function (pathStringArg) {
|
||||
var urlRegex = /http[s|\s]:\/\/.*/i;
|
||||
if (urlRegex.exec(pathStringArg)) {
|
||||
return "url";
|
||||
}
|
||||
else {
|
||||
return "local";
|
||||
}
|
||||
;
|
||||
};
|
||||
|
||||
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbInNtYXJ0cGF0aC5nZXQudHMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6IkFBR1csWUFBSSxHQUFHLFVBQVMsYUFBb0I7SUFDM0MsSUFBSSxRQUFRLEdBQUcsb0JBQW9CLENBQUE7SUFDbkMsRUFBRSxDQUFBLENBQUMsUUFBUSxDQUFDLElBQUksQ0FBQyxhQUFhLENBQUMsQ0FBQyxDQUFBLENBQUM7UUFDN0IsTUFBTSxDQUFDLEtBQUssQ0FBQztJQUNqQixDQUFDO0lBQUMsSUFBSSxDQUFDLENBQUM7UUFDSixNQUFNLENBQUMsT0FBTyxDQUFDO0lBQ25CLENBQUM7SUFBQSxDQUFDO0FBQ04sQ0FBQyxDQUFDIiwiZmlsZSI6InNtYXJ0cGF0aC5nZXQuanMiLCJzb3VyY2VzQ29udGVudCI6WyIvLy8gPHJlZmVyZW5jZSBwYXRoPVwidHlwaW5ncy9tYWluLmQudHNcIiAvPlxuaW1wb3J0IHBsdWdpbnMgPSByZXF1aXJlKFwiLi9zbWFydHBhdGgucGx1Z2luc1wiKTtcblxuZXhwb3J0IGxldCB0eXBlID0gZnVuY3Rpb24ocGF0aFN0cmluZ0FyZzpzdHJpbmcpOnN0cmluZyB7XG4gICAgbGV0IHVybFJlZ2V4ID0gL2h0dHBbc3xcXHNdOlxcL1xcLy4qL2lcbiAgICBpZih1cmxSZWdleC5leGVjKHBhdGhTdHJpbmdBcmcpKXtcbiAgICAgICAgcmV0dXJuIFwidXJsXCI7XG4gICAgfSBlbHNlIHtcbiAgICAgICAgcmV0dXJuIFwibG9jYWxcIjtcbiAgICB9O1xufTsiXSwic291cmNlUm9vdCI6Ii9zb3VyY2UvIn0=
|
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==
|
39
dist/smartpath.transform.js
vendored
39
dist/smartpath.transform.js
vendored
@ -1,39 +0,0 @@
|
||||
/// <reference path="typings/main.d.ts" />
|
||||
var plugins = require("./smartpath.plugins");
|
||||
/* ------------------------------------------ *
|
||||
* ------------ helpers --------------------- *
|
||||
* ------------------------------------------ */
|
||||
var makeAbsolute = function (localPathArg, baseArg) {
|
||||
var absolutePath;
|
||||
if (baseArg) {
|
||||
absolutePath = plugins.path.join(baseArg, localPathArg);
|
||||
}
|
||||
else {
|
||||
absolutePath = plugins.path.resolve(localPathArg);
|
||||
}
|
||||
return absolutePath;
|
||||
};
|
||||
/* ------------------------------------------ *
|
||||
* ------- export functions ----------------- *
|
||||
* ------------------------------------------ */
|
||||
exports.toAbsolute = 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;
|
||||
}
|
||||
};
|
||||
|
||||
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbInNtYXJ0cGF0aC50cmFuc2Zvcm0udHMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6IkFBQUEsMENBQTBDO0FBQzFDLElBQU8sT0FBTyxXQUFXLHFCQUFxQixDQUFDLENBQUM7QUFFaEQ7O2dEQUVnRDtBQUNoRCxJQUFJLFlBQVksR0FBRyxVQUFTLFlBQW1CLEVBQUUsT0FBZTtJQUM1RCxJQUFJLFlBQW1CLENBQUM7SUFDeEIsRUFBRSxDQUFBLENB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LS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tICovXG5leHBvcnQgbGV0IHRvQWJzb2x1dGUgPSBmdW5jdGlvbihyZWxhdGl2ZUFyZzphbnksIGJhc2VBcmc/OnN0cmluZyk6YW55IHtcbiAgICBpZih0eXBlb2YgcmVsYXRpdmVBcmcgPT09IFwic3RyaW5nXCIpe1xuICAgICAgICByZXR1cm4gbWFrZUFic29sdXRlKHJlbGF0aXZlQXJnLGJhc2VBcmcpO1xuICAgIH0gZWxzZSBpZihBcnJheS5pc0FycmF5KHJlbGF0aXZlQXJnKSl7XG4gICAgICAgIGxldCByZWxhdGl2ZUFycmF5ID0gcmVsYXRpdmVBcmdcbiAgICAgICAgbGV0IGFic29sdXRlQXJyYXk6c3RyaW5nW10gPSBbXTtcbiAgICAgICAgZm9yIChsZXQga2V5IGluIHJlbGF0aXZlQXJyYXkpe1xuICAgICAgICAgICAgYWJzb2x1dGVBcnJheS5wdXNoKG1ha2VBYnNvbHV0ZShyZWxhdGl2ZUFycmF5W2tleV0sYmFzZUFyZykpO1xuICAgICAgICB9O1xuICAgICAgICByZXR1cm4gYWJzb2x1dGVBcnJheTtcbiAgICB9IGVsc2Uge1xuICAgICAgICBwbHVnaW5zLmJlYXV0eWxvZy5lcnJvcihcInNtYXJ0cGF0aC5hYnNvbHV0ZSgpIGNvdWxkIG5vdCBtYWtlIHNlbnNlIG9mIHRoZSBpbnB1dC4gXCIgK1xuICAgICAgICAgICAgXCJJbnB1dCBpcyBuZWl0aGVyIFN0cmluZyBub3IgQXJyYXlcIik7XG4gICAgICAgIHJldHVybiBmYWxzZTtcbiAgICB9XG59OyJdLCJzb3VyY2VSb290IjoiL3NvdXJjZS8ifQ==
|
@ -1,6 +1,6 @@
|
||||
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
|
||||
of this software and associated documentation files (the "Software"), to deal
|
16
npmextra.json
Normal file
16
npmextra.json
Normal file
@ -0,0 +1,16 @@
|
||||
{
|
||||
"npmci": {
|
||||
"npmAccessLevel": "public"
|
||||
},
|
||||
"gitzone": {
|
||||
"projectType": "npm",
|
||||
"module": {
|
||||
"githost": "gitlab.com",
|
||||
"gitscope": "push.rocks",
|
||||
"gitrepo": "smartpath",
|
||||
"description": "offers smart ways to handle paths",
|
||||
"npmPackagename": "@push.rocks/smartpath",
|
||||
"license": "MIT"
|
||||
}
|
||||
}
|
||||
}
|
@ -1,4 +0,0 @@
|
||||
{
|
||||
"mode": "default",
|
||||
"coveralls": "true"
|
||||
}
|
42
package.json
42
package.json
@ -1,10 +1,15 @@
|
||||
{
|
||||
"name": "smartpath",
|
||||
"version": "3.0.1",
|
||||
"name": "@push.rocks/smartpath",
|
||||
"version": "5.0.11",
|
||||
"private": false,
|
||||
"description": "offers smart ways to handle paths",
|
||||
"main": "dist/index.js",
|
||||
"main": "dist_ts/index.js",
|
||||
"typings": "dist_ts/index.d.ts",
|
||||
"type": "module",
|
||||
"scripts": {
|
||||
"test": "(npmts)"
|
||||
"test": "(tstest test)",
|
||||
"build": "(tsbuild --allowimplicitany)",
|
||||
"buildDocs": "tsdoc"
|
||||
},
|
||||
"repository": {
|
||||
"type": "git",
|
||||
@ -15,17 +20,32 @@
|
||||
"jade",
|
||||
"template"
|
||||
],
|
||||
"author": "Smart Coordination GmbH <office@push.rocks> (https://push.rocks)",
|
||||
"author": "Lossless GmbH <office@lossless.com> (https://lossless.com)",
|
||||
"license": "MIT",
|
||||
"bugs": {
|
||||
"url": "https://github.com/pushrocks/smartpath/issues"
|
||||
},
|
||||
"homepage": "https://github.com/pushrocks/smartpath",
|
||||
"dependencies": {
|
||||
"beautylog": "^3.1.2"
|
||||
},
|
||||
"devDependencies": {
|
||||
"npmts": "^3.3.2",
|
||||
"should": "^8.2.2"
|
||||
}
|
||||
"@gitzone/tsbuild": "^2.1.66",
|
||||
"@gitzone/tsrun": "^1.2.42",
|
||||
"@gitzone/tstest": "^1.0.74",
|
||||
"@pushrocks/tapbundle": "^5.0.8",
|
||||
"@types/node": "^20.4.1"
|
||||
},
|
||||
"files": [
|
||||
"ts/**/*",
|
||||
"ts_web/**/*",
|
||||
"dist/**/*",
|
||||
"dist_*/**/*",
|
||||
"dist_ts/**/*",
|
||||
"dist_ts_web/**/*",
|
||||
"assets/**/*",
|
||||
"cli.js",
|
||||
"npmextra.json",
|
||||
"readme.md"
|
||||
],
|
||||
"browserslist": [
|
||||
"last 1 chrome versions"
|
||||
]
|
||||
}
|
||||
|
4648
pnpm-lock.yaml
generated
Normal file
4648
pnpm-lock.yaml
generated
Normal file
File diff suppressed because it is too large
Load Diff
43
readme.md
Normal file
43
readme.md
Normal file
@ -0,0 +1,43 @@
|
||||
# @push.rocks/smartpath
|
||||
offers smart ways to handle paths
|
||||
|
||||
## Availabililty and Links
|
||||
* [npmjs.org (npm package)](https://www.npmjs.com/package/@push.rocks/smartpath)
|
||||
* [gitlab.com (source)](https://gitlab.com/push.rocks/smartpath)
|
||||
* [github.com (source mirror)](https://github.com/push.rocks/smartpath)
|
||||
* [docs (typedoc)](https://push.rocks.gitlab.io/smartpath/)
|
||||
|
||||
## Status for master
|
||||
|
||||
Status Category | Status Badge
|
||||
-- | --
|
||||
GitLab Pipelines | [](https://lossless.cloud)
|
||||
GitLab Pipline Test Coverage | [](https://lossless.cloud)
|
||||
npm | [](https://lossless.cloud)
|
||||
Snyk | [](https://lossless.cloud)
|
||||
TypeScript Support | [](https://lossless.cloud)
|
||||
node Support | [](https://nodejs.org/dist/latest-v10.x/docs/api/)
|
||||
Code Style | [](https://lossless.cloud)
|
||||
PackagePhobia (total standalone install weight) | [](https://lossless.cloud)
|
||||
PackagePhobia (package size on registry) | [](https://lossless.cloud)
|
||||
BundlePhobia (total size when bundled) | [](https://lossless.cloud)
|
||||
|
||||
## 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.
|
||||
|
||||
## Legal
|
||||
> MIT licensed | **©** [Task Venture Capital GmbH](https://task.vc)
|
||||
| By using this npm module you agree to our [privacy policy](https://lossless.gmbH/privacy)
|
39
test/test.js
39
test/test.js
@ -1,39 +0,0 @@
|
||||
/// <reference path="../ts/typings/main.d.ts" />
|
||||
var should = require("should");
|
||||
var smartpath = require("../dist/index.js");
|
||||
describe("smartpath", function () {
|
||||
describe(".transform", function () {
|
||||
describe("toAbsolute()", 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.transform.toAbsolute(relativeString).should.startWith("/");
|
||||
smartpath.transform.toAbsolute(relativeString).should.endWith(relativeString);
|
||||
smartpath.transform.toAbsolute(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.transform.toAbsolute(relativeArray);
|
||||
absoluteArray[2].should.startWith("/");
|
||||
absoluteArray[2].should.endWith(relativeString2);
|
||||
});
|
||||
it("should return false if neither String nor Array", function () {
|
||||
smartpath.transform.toAbsolute(3).should.be.false();
|
||||
});
|
||||
});
|
||||
});
|
||||
describe(".get", function () {
|
||||
describe(".type()", function () {
|
||||
it("should return 'url' for an URL", function () {
|
||||
smartpath.get.type("https://push.rocks/some/url").should.equal("url");
|
||||
smartpath.get.type("https://push.rocks/some/url").should.not.equal("local");
|
||||
});
|
||||
it("should return 'path' for a Path", function () {
|
||||
smartpath.get.type("/some/absolute/path/").should.equal("local");
|
||||
smartpath.get.type("./some/relative/path/").should.not.equal("url");
|
||||
});
|
||||
});
|
||||
});
|
||||
});
|
||||
//# sourceMappingURL=test.js.map
|
@ -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,QAAQ,CAAC,cAAc,EAAC;YACpB,IAAI,UAAU,GAAG,UAAU,CAAC;YAC5B,IAAI,cAAc,GAAG,sBAAsB,CAAC;YAC5C,IAAI,eAAe,GAAG,4BAA4B,CAAC;YACnD,IAAI,aAAa,GAAG,CAAC,cAAc,EAAC,cAAc,EAAC,eAAe,CAAC,CAAC;YACpE,EAAE,CAAC,+BAA+B,EAAC;gBAC/B,SAAS,CAAC,SAAS,CAAC,UAAU,CAAC,cAAc,CAAC,CAAC,MAAM,CAAC,SAAS,CAAC,GAAG,CAAC,CAAC;gBACrE,SAAS,CAAC,SAAS,CAAC,UAAU,CAAC,cAAc,CAAC,CAAC,MAAM,CAAC,OAAO,CAAC,cAAc,CAAC,CAAC;gBAC9E,SAAS,CAAC,SAAS,CAAC,UAAU,CAAC,cAAc,EAAC,UAAU,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,+BAA+B,CAAC,CAAC;YAC5G,CAAC,CAAC,CAAC;YACH,EAAE,CAAC,uEAAuE,EAAC;gBACvE,IAAI,aAAa,GAAG,SAAS,CAAC,SAAS,CAAC,UAAU,CAAC,aAAa,CAAC,CAAC;gBAClE,aAAa,CAAC,CAAC,CAAC,CAAC,MAAM,CAAC,SAAS,CAAC,GAAG,CAAC,CAAC;gBACvC,aAAa,CAAC,CAAC,CAAC,CAAC,MAAM,CAAC,OAAO,CAAC,eAAe,CAAC,CAAC;YAErD,CAAC,CAAC,CAAA;YACF,EAAE,CAAC,iDAAiD,EAAC;gBACjD,SAAS,CAAC,SAAS,CAAC,UAAU,CAAC,CAAC,CAAC,CAAC,MAAM,CAAC,EAAE,CAAC,KAAK,EAAE,CAAC;YACxD,CAAC,CAAC,CAAC;QACP,CAAC,CAAC,CAAC;IACP,CAAC,CAAC,CAAC;IACH,QAAQ,CAAC,MAAM,EAAC;QACZ,QAAQ,CAAC,SAAS,EAAC;YACf,EAAE,CAAC,gCAAgC,EAAC;gBAChC,SAAS,CAAC,GAAG,CAAC,IAAI,CAAC,6BAA6B,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC;gBACtE,SAAS,CAAC,GAAG,CAAC,IAAI,CAAC,6BAA6B,CAAC,CAAC,MAAM,CAAC,GAAG,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC;YAChF,CAAC,CAAC,CAAC;YACH,EAAE,CAAC,iCAAiC,EAAC;gBACjC,SAAS,CAAC,GAAG,CAAC,IAAI,CAAC,sBAAsB,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC;gBACjE,SAAS,CAAC,GAAG,CAAC,IAAI,CAAC,uBAAuB,CAAC,CAAC,MAAM,CAAC,GAAG,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC;YACxE,CAAC,CAAC,CAAC;QACP,CAAC,CAAC,CAAC;IACP,CAAC,CAAC,CAAC;AACP,CAAC,CAAC,CAAC"}
|
102
test/test.ts
102
test/test.ts
@ -1,40 +1,66 @@
|
||||
/// <reference path="../ts/typings/main.d.ts" />
|
||||
let should = require("should");
|
||||
let smartpath = require("../dist/index.js");
|
||||
import { tap, expect, expectAsync } from '@pushrocks/tapbundle';
|
||||
import * as smartpath from '../ts/index.js';
|
||||
|
||||
describe("smartpath",function(){
|
||||
describe(".transform",function(){
|
||||
describe("toAbsolute()",function(){
|
||||
let baseString = "/basedir";
|
||||
let relativeString = "somedir/somefile.txt";
|
||||
let relativeString2 = "anotherdir/anotherfile.txt";
|
||||
let relativeArray = [relativeString,relativeString,relativeString2];
|
||||
it("should make a string absolute",function(){
|
||||
smartpath.transform.toAbsolute(relativeString).should.startWith("/");
|
||||
smartpath.transform.toAbsolute(relativeString).should.endWith(relativeString);
|
||||
smartpath.transform.toAbsolute(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.transform.toAbsolute(relativeArray);
|
||||
absoluteArray[2].should.startWith("/");
|
||||
absoluteArray[2].should.endWith(relativeString2);
|
||||
|
||||
})
|
||||
it("should return false if neither String nor Array",function(){
|
||||
smartpath.transform.toAbsolute(3).should.be.false();
|
||||
});
|
||||
});
|
||||
});
|
||||
describe(".get",function(){
|
||||
describe(".type()",function(){
|
||||
it("should return 'url' for an URL",function(){
|
||||
smartpath.get.type("https://push.rocks/some/url").should.equal("url");
|
||||
smartpath.get.type("https://push.rocks/some/url").should.not.equal("local");
|
||||
});
|
||||
it("should return 'path' for a Path",function(){
|
||||
smartpath.get.type("/some/absolute/path/").should.equal("local");
|
||||
smartpath.get.type("./some/relative/path/").should.not.equal("url");
|
||||
});
|
||||
});
|
||||
});
|
||||
let mySmartpath: smartpath.Smartpath;
|
||||
tap.test('expect create a valid instance', async () => {
|
||||
mySmartpath = new smartpath.Smartpath('/some/path/to/some.file');
|
||||
expect(mySmartpath).toBeInstanceOf(smartpath.Smartpath);
|
||||
expect(mySmartpath.pathLevelsBackwards.length === 5).toBeTrue();
|
||||
});
|
||||
|
||||
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)).toBeTrue();
|
||||
});
|
||||
tap.test('expect be false for a directory path', async () => {
|
||||
expect(smartpath.check.isFile(dirPathString)).toBeFalse();
|
||||
expect(smartpath.check.isFile(dirPathString2)).toBeFalse();
|
||||
});
|
||||
|
||||
tap.test('expect be true for a directory path', async () => {
|
||||
expect(smartpath.check.isDir(dirPathString)).toBeTrue();
|
||||
|
||||
expect(smartpath.check.isDir(dirPathString2)).toBeTrue();
|
||||
});
|
||||
|
||||
tap.test('expect be false for a file path', async () => {
|
||||
expect(smartpath.check.isDir(filePathString)).toBeFalse();
|
||||
});
|
||||
|
||||
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)).toStartWith('/');
|
||||
expect(smartpath.transform.toAbsolute(relativeString)).toEndWith(relativeString);
|
||||
expect(smartpath.transform.toAbsolute(relativeString, baseString)).toEqual(
|
||||
'/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]).toStartWith('/');
|
||||
expect(absoluteArray[2]).toEndWith(relativeString2);
|
||||
});
|
||||
|
||||
tap.test("expect return 'url' for an URL", async () => {
|
||||
expect(smartpath.get.type('https://push.rocks/some/url')).toEqual('url');
|
||||
expect(smartpath.get.type('https://push.rocks/some/url')).not.toEqual('local');
|
||||
});
|
||||
tap.test("expect return 'path' for a Path", async () => {
|
||||
expect(smartpath.get.type('/some/absolute/path/')).toEqual('local');
|
||||
expect(smartpath.get.type('./some/relative/path/')).not.toEqual('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();
|
||||
|
8
ts/00_commitinfo_data.ts
Normal file
8
ts/00_commitinfo_data.ts
Normal file
@ -0,0 +1,8 @@
|
||||
/**
|
||||
* autocreated commitinfo by @pushrocks/commitinfo
|
||||
*/
|
||||
export const commitinfo = {
|
||||
name: '@push.rocks/smartpath',
|
||||
version: '5.0.11',
|
||||
description: 'offers smart ways to handle paths'
|
||||
}
|
21
ts/index.ts
21
ts/index.ts
@ -1,17 +1,8 @@
|
||||
/// <reference path="typings/main.d.ts" />
|
||||
import plugins = require("./smartpath.plugins");
|
||||
import SmartpathTransform = require("./smartpath.transform");
|
||||
import SmartpathGet = require("./smartpath.get");
|
||||
// import modules
|
||||
import * as check from './smartpath.check.js';
|
||||
import * as get from './smartpath.get.js';
|
||||
import * as transform from './smartpath.transform.js';
|
||||
|
||||
/**
|
||||
*
|
||||
* @type {{getPath: (function(any): undefined)}}
|
||||
*/
|
||||
let smartpath = {
|
||||
transform: SmartpathTransform,
|
||||
get: SmartpathGet
|
||||
export { check, get, transform };
|
||||
|
||||
};
|
||||
|
||||
|
||||
export = smartpath;
|
||||
export * from './smartpath.classes.smartpath.js';
|
||||
|
9
ts/smartpath.check.ts
Normal file
9
ts/smartpath.check.ts
Normal file
@ -0,0 +1,9 @@
|
||||
import * as plugins from './smartpath.plugins.js';
|
||||
|
||||
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.js';
|
||||
import * as getMod from './smartpath.get.js';
|
||||
|
||||
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);
|
||||
}
|
||||
}
|
@ -1,11 +1,48 @@
|
||||
/// <reference path="typings/main.d.ts" />
|
||||
import plugins = require("./smartpath.plugins");
|
||||
import * as plugins from './smartpath.plugins.js';
|
||||
export type TPathType = 'url' | 'local';
|
||||
|
||||
export let type = function(pathStringArg:string):string {
|
||||
let urlRegex = /http[s|\s]:\/\/.*/i
|
||||
if(urlRegex.exec(pathStringArg)){
|
||||
return "url";
|
||||
/**
|
||||
* returns the type of the given path. Can be "url" or "local"
|
||||
*/
|
||||
export const type = (pathStringArg: string): TPathType => {
|
||||
const urlRegex = /http[s|\s]:\/\/.*/i;
|
||||
if (urlRegex.exec(pathStringArg)) {
|
||||
return 'url';
|
||||
} else {
|
||||
return "local";
|
||||
};
|
||||
return 'local';
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* gets the dirname from import.meta.url
|
||||
*/
|
||||
export const dirnameFromImportMetaUrl = (importMetaUrlArg: string) => {
|
||||
return plugins.path.dirname(plugins.url.fileURLToPath(importMetaUrlArg));
|
||||
};
|
||||
|
||||
/**
|
||||
* returns homedir as absolute path
|
||||
* @param pathArgument if a pathargument is given, ~ is being replaced with the homedir
|
||||
* @returns
|
||||
*/
|
||||
export const home = (pathArgument?: string) => {
|
||||
if (pathArgument) {
|
||||
return pathArgument.replace('~', plugins.os.homedir());
|
||||
} else {
|
||||
return plugins.os.homedir();
|
||||
}
|
||||
};
|
||||
|
||||
export type TSystemArg = 'dynamic' | 'windows' | 'linux' | 'osx';
|
||||
|
||||
export const pathLevels = (pathArg: string, systemArg: TSystemArg = 'dynamic') => {
|
||||
let pathLevelArray: string[];
|
||||
if (systemArg === 'dynamic') {
|
||||
pathLevelArray = pathArg.split(plugins.path.sep);
|
||||
}
|
||||
return pathLevelArray;
|
||||
};
|
||||
|
||||
export const pathLevelsBackwards = (pathArg: string, systemArg?: TSystemArg) => {
|
||||
return pathLevels(pathArg, systemArg).reverse();
|
||||
};
|
@ -1,3 +1,5 @@
|
||||
/// <reference path="./typings/main.d.ts" />
|
||||
export var beautylog = require ("beautylog");
|
||||
export var path = require("path");
|
||||
import * as os from 'os';
|
||||
import * as path from 'path';
|
||||
import * as url from 'url';
|
||||
|
||||
export { os, path, url };
|
||||
|
@ -1,15 +1,19 @@
|
||||
/// <reference path="typings/main.d.ts" />
|
||||
import plugins = require("./smartpath.plugins");
|
||||
import * as plugins from './smartpath.plugins.js';
|
||||
|
||||
/* ------------------------------------------ *
|
||||
* ------------ helpers --------------------- *
|
||||
* ------------------------------------------ */
|
||||
let makeAbsolute = function(localPathArg:string, baseArg?:string):string {
|
||||
let absolutePath:string;
|
||||
if(baseArg){
|
||||
absolutePath = plugins.path.join(baseArg,localPathArg);
|
||||
} else {
|
||||
|
||||
// checks a file
|
||||
export const makeAbsolute = (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;
|
||||
};
|
||||
@ -17,19 +21,21 @@ let makeAbsolute = function(localPathArg:string, baseArg?:string):string {
|
||||
/* ------------------------------------------ *
|
||||
* ------- export functions ----------------- *
|
||||
* ------------------------------------------ */
|
||||
export let toAbsolute = 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));
|
||||
};
|
||||
export const toAbsolute = (relativeArg: string | string[], baseArg?: string): string | string[] => {
|
||||
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;
|
||||
console.error(
|
||||
'smartpath.absolute() could not make sense of the input. ' +
|
||||
'Input is neither String nor Array'
|
||||
);
|
||||
return null;
|
||||
}
|
||||
};
|
@ -1,6 +0,0 @@
|
||||
{
|
||||
"ambientDependencies": {
|
||||
"mocha": "github:DefinitelyTyped/DefinitelyTyped/mocha/mocha.d.ts#d6dd320291705694ba8e1a79497a908e9f5e6617",
|
||||
"node": "github:DefinitelyTyped/DefinitelyTyped/node/node.d.ts#efa0c1196d7280640e624ac1e7fa604502e7bd63"
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user