tar-dependency 0.1.0 → 0.3.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.nvmrc +1 -0
- package/README.md +43 -2
- package/bin/cmd.js +6 -5
- package/eslint.config.js +46 -0
- package/index.js +17 -19
- package/package.json +45 -79
package/.nvmrc
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
24
|
package/README.md
CHANGED
|
@@ -15,7 +15,7 @@ We created this tool to replace [Bower](https://bower.io/), where packages are n
|
|
|
15
15
|
|
|
16
16
|
## Requirements
|
|
17
17
|
|
|
18
|
-
This library needs at least NodeJS >=
|
|
18
|
+
This library needs at least NodeJS >= 20
|
|
19
19
|
|
|
20
20
|
## Installation
|
|
21
21
|
|
|
@@ -91,4 +91,45 @@ and then install them with
|
|
|
91
91
|
|
|
92
92
|
`tar-dependency install`
|
|
93
93
|
|
|
94
|
-
|
|
94
|
+
### Authentication / Private repositories
|
|
95
|
+
|
|
96
|
+
URLs support `${ENV_VAR}` placeholders, which are expanded from environment variables at install time. This keeps secrets out of `package.json` and version control.
|
|
97
|
+
|
|
98
|
+
For example, to authenticate against a private GitLab instance:
|
|
99
|
+
|
|
100
|
+
```json
|
|
101
|
+
{
|
|
102
|
+
"tarDependencies": {
|
|
103
|
+
"components/components-ext": {
|
|
104
|
+
"url": "https://gitlab.kadenpartner.ch/kp/extjs/repository/4.2.6-min/archive.tgz?private_token=${KP_GITLAB_TOKEN}",
|
|
105
|
+
"strip": 1
|
|
106
|
+
}
|
|
107
|
+
}
|
|
108
|
+
}
|
|
109
|
+
```
|
|
110
|
+
|
|
111
|
+
Store the token in your shell environment (e.g. `~/.zshenv` or `~/.zshrc`):
|
|
112
|
+
|
|
113
|
+
```bash
|
|
114
|
+
export KP_GITLAB_TOKEN=glpat-xxxx
|
|
115
|
+
```
|
|
116
|
+
|
|
117
|
+
The raw URL (with the placeholder, not the expanded value) is printed to the console, so tokens are never leaked in logs.
|
|
118
|
+
|
|
119
|
+
## Changelog
|
|
120
|
+
|
|
121
|
+
### 0.3.0 - Mar 2026
|
|
122
|
+
|
|
123
|
+
* Added `${ENV_VAR}` placeholder support in URLs for authentication against private registries
|
|
124
|
+
|
|
125
|
+
### 0.2.0 - Feb 2025
|
|
126
|
+
|
|
127
|
+
* [breaking] Updated to NodeJS >= 20 with ES Modules
|
|
128
|
+
* [breaking] You need a NodeJS version that supports ES Modules (~ V.14.0)
|
|
129
|
+
* Updated dependant packages
|
|
130
|
+
|
|
131
|
+
### 0.1.0
|
|
132
|
+
|
|
133
|
+
Initial release
|
|
134
|
+
|
|
135
|
+
(c) 2017-2026 alex@alexi.ch
|
package/bin/cmd.js
CHANGED
|
@@ -4,13 +4,14 @@
|
|
|
4
4
|
*
|
|
5
5
|
* It assumes a package.json in the actual working directory.
|
|
6
6
|
*
|
|
7
|
-
* (c) 2017 alex@alexi.ch
|
|
7
|
+
* (c) 2017-2025 alex@alexi.ch
|
|
8
8
|
*/
|
|
9
9
|
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
10
|
+
import process from 'node:process';
|
|
11
|
+
import lib from '../index.js';
|
|
12
|
+
import jsonfile from 'jsonfile';
|
|
13
|
+
import path from 'path';
|
|
14
|
+
import { program } from 'commander';
|
|
14
15
|
|
|
15
16
|
function setWorkingDir(dir) {
|
|
16
17
|
process.chdir(dir);
|
package/eslint.config.js
ADDED
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
import eslintPluginPrettierRecommended from 'eslint-plugin-prettier/recommended';
|
|
2
|
+
import json from 'eslint-plugin-json';
|
|
3
|
+
|
|
4
|
+
// eslint.config.js
|
|
5
|
+
export default [
|
|
6
|
+
eslintPluginPrettierRecommended,
|
|
7
|
+
{
|
|
8
|
+
files: ['**/*.json'],
|
|
9
|
+
...json.configs['recommended']
|
|
10
|
+
},
|
|
11
|
+
{
|
|
12
|
+
// extends: ['prettier', 'plugin:json/recommended'],
|
|
13
|
+
languageOptions: {
|
|
14
|
+
ecmaVersion: 2017
|
|
15
|
+
},
|
|
16
|
+
// env: {
|
|
17
|
+
// node: true
|
|
18
|
+
// },
|
|
19
|
+
// plugins: ['prettier', 'json'],
|
|
20
|
+
rules: {
|
|
21
|
+
'prettier/prettier': [
|
|
22
|
+
'error',
|
|
23
|
+
{
|
|
24
|
+
singleQuote: true,
|
|
25
|
+
tabWidth: 4,
|
|
26
|
+
printWidth: 120
|
|
27
|
+
}
|
|
28
|
+
],
|
|
29
|
+
'no-unused-vars': [
|
|
30
|
+
'error',
|
|
31
|
+
{
|
|
32
|
+
vars: 'all',
|
|
33
|
+
args: 'none'
|
|
34
|
+
}
|
|
35
|
+
],
|
|
36
|
+
semi: ['error', 'always'],
|
|
37
|
+
curly: 'error',
|
|
38
|
+
eqeqeq: 'error',
|
|
39
|
+
'no-eval': 'error',
|
|
40
|
+
'no-loop-func': 'error',
|
|
41
|
+
radix: 'error',
|
|
42
|
+
'comma-dangle': 'error',
|
|
43
|
+
'no-undef': 'error'
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
];
|
package/index.js
CHANGED
|
@@ -1,15 +1,16 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* tar-dependency module
|
|
3
3
|
*
|
|
4
|
-
* (c) 2017 alex@alexi.ch
|
|
4
|
+
* (c) 2017-2025 alex@alexi.ch
|
|
5
5
|
*/
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
6
|
+
import process from 'node:process';
|
|
7
|
+
import console from 'node:console';
|
|
8
|
+
import path from 'path';
|
|
9
|
+
import jsonfile from 'jsonfile';
|
|
10
|
+
import { rimraf } from 'rimraf';
|
|
11
|
+
import { mkdirp } from 'mkdirp';
|
|
12
|
+
import * as tar from 'tar';
|
|
13
|
+
import fetch from 'node-fetch';
|
|
13
14
|
|
|
14
15
|
function normalizePathKey(str) {
|
|
15
16
|
return (str || '').replace(/(^\/)|(\/$)/g, ''); // remove leading/trailing slashes)
|
|
@@ -30,21 +31,18 @@ function normalizePathKey(str) {
|
|
|
30
31
|
*
|
|
31
32
|
* This function returns a promise that resolves when all dependencies are installed.
|
|
32
33
|
*/
|
|
33
|
-
async function installTarDependencies(config
|
|
34
|
+
async function installTarDependencies(config) {
|
|
34
35
|
config = config || {};
|
|
35
36
|
const deps = config.tarDependencies || {};
|
|
36
37
|
|
|
37
|
-
destKey = normalizePathKey(destKey);
|
|
38
38
|
for (const key of Object.keys(deps)) {
|
|
39
|
-
if (destKey && key !== destKey) {
|
|
40
|
-
return;
|
|
41
|
-
}
|
|
42
39
|
const fullOutdir = path.join(process.cwd(), key);
|
|
43
|
-
const
|
|
40
|
+
const rawUrl = deps[key].url;
|
|
41
|
+
const url = rawUrl.replaceAll(/\$\{(\w+)\}/g, (_, name) => encodeURIComponent(process.env[name] ?? ''));
|
|
44
42
|
const strip = deps[key].strip === undefined ? 1 : Number(deps[key].strip);
|
|
45
43
|
|
|
46
|
-
console.log('tar package: ' +
|
|
47
|
-
await
|
|
44
|
+
console.log('tar package: ' + rawUrl + ' => ' + key);
|
|
45
|
+
await rimraf(fullOutdir);
|
|
48
46
|
await mkdirp(fullOutdir);
|
|
49
47
|
|
|
50
48
|
const response = await fetch(url);
|
|
@@ -96,7 +94,7 @@ async function removeArchive(config, destDir) {
|
|
|
96
94
|
}
|
|
97
95
|
|
|
98
96
|
const fullOutdir = path.join(process.cwd(), destDir);
|
|
99
|
-
await
|
|
97
|
+
await rimraf(fullOutdir);
|
|
100
98
|
}
|
|
101
99
|
|
|
102
100
|
/*
|
|
@@ -107,10 +105,10 @@ async function removeArchive(config, destDir) {
|
|
|
107
105
|
*/
|
|
108
106
|
async function saveConf(config, file) {
|
|
109
107
|
config = config || {};
|
|
110
|
-
await
|
|
108
|
+
await jsonfile.writeFile(file, config, { spaces: 2 });
|
|
111
109
|
}
|
|
112
110
|
|
|
113
|
-
|
|
111
|
+
export default {
|
|
114
112
|
install: installTarDependencies,
|
|
115
113
|
add: addArchive,
|
|
116
114
|
remove: removeArchive,
|
package/package.json
CHANGED
|
@@ -1,83 +1,49 @@
|
|
|
1
1
|
{
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
2
|
+
"name": "tar-dependency",
|
|
3
|
+
"version": "0.3.0",
|
|
4
|
+
"description": "Fetches .tar(.gz) archives defined in package.json and extracts them to a specific location.",
|
|
5
|
+
"main": "index.js",
|
|
6
|
+
"type": "module",
|
|
7
|
+
"scripts": {
|
|
8
|
+
"test": "echo \"Error: no test specified\" && exit 1"
|
|
9
|
+
},
|
|
10
|
+
"author": "Alexander Schenkel",
|
|
11
|
+
"email": "alex@alexi.ch",
|
|
12
|
+
"license": "MIT",
|
|
13
|
+
"dependencies": {
|
|
14
|
+
"commander": "^13.1.0",
|
|
15
|
+
"jsonfile": "^6.2.1",
|
|
16
|
+
"mkdirp": "^3.0.1",
|
|
17
|
+
"node-fetch": "^2.6.5",
|
|
18
|
+
"rimraf": "^6.1.3",
|
|
19
|
+
"tar": "^7.5.16"
|
|
20
|
+
},
|
|
21
|
+
"devDependencies": {
|
|
22
|
+
"eslint": "^9.20.0",
|
|
23
|
+
"eslint-config-prettier": "^10.0.1",
|
|
24
|
+
"eslint-plugin-json": "^4.0.1",
|
|
25
|
+
"eslint-plugin-prettier": "^5.2.3",
|
|
26
|
+
"prettier": "^3.5.0"
|
|
27
|
+
},
|
|
28
|
+
"bin": {
|
|
29
|
+
"tar-dependency": "bin/cmd.js"
|
|
30
|
+
},
|
|
31
|
+
"prettier": {
|
|
32
|
+
"printWidth": 120,
|
|
33
|
+
"tabWidth": 4,
|
|
34
|
+
"useTabs": false,
|
|
35
|
+
"semi": true,
|
|
36
|
+
"singleQuote": true,
|
|
37
|
+
"trailingComma": "none"
|
|
38
|
+
},
|
|
39
|
+
"tarDependencies": {
|
|
40
|
+
"packages/fontawesome": {
|
|
41
|
+
"url": "http://reposerver.kp.local/lib/fontawesome-pro-6.7.2-web.tar.gz",
|
|
42
|
+
"strip": 1
|
|
8
43
|
},
|
|
9
|
-
"
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
"dependencies": {
|
|
13
|
-
"commander": "^8.2.0",
|
|
14
|
-
"jsonfile": "^6.1.0",
|
|
15
|
-
"mkdirp": "^1.0.4",
|
|
16
|
-
"node-fetch": "^2.6.5",
|
|
17
|
-
"rimraf": "^3.0.2",
|
|
18
|
-
"tar": "^6.1.11"
|
|
19
|
-
},
|
|
20
|
-
"devDependencies": {
|
|
21
|
-
"eslint": "^7.32.0",
|
|
22
|
-
"eslint-config-prettier": "^8.3.0",
|
|
23
|
-
"eslint-plugin-json": "^3.1.0",
|
|
24
|
-
"eslint-plugin-prettier": "^4.0.0",
|
|
25
|
-
"prettier": "^2.4.1"
|
|
26
|
-
},
|
|
27
|
-
"bin": {
|
|
28
|
-
"tar-dependency": "bin/cmd.js"
|
|
29
|
-
},
|
|
30
|
-
"eslintConfig": {
|
|
31
|
-
"root": true,
|
|
32
|
-
"parserOptions": {
|
|
33
|
-
"ecmaVersion": 2017
|
|
34
|
-
},
|
|
35
|
-
"extends": [
|
|
36
|
-
"prettier",
|
|
37
|
-
"plugin:json/recommended"
|
|
38
|
-
],
|
|
39
|
-
"env": {
|
|
40
|
-
"node": true
|
|
41
|
-
},
|
|
42
|
-
"plugins": [
|
|
43
|
-
"prettier",
|
|
44
|
-
"json"
|
|
45
|
-
],
|
|
46
|
-
"rules": {
|
|
47
|
-
"prettier/prettier": [
|
|
48
|
-
"error",
|
|
49
|
-
{
|
|
50
|
-
"singleQuote": true,
|
|
51
|
-
"tabWidth": 4,
|
|
52
|
-
"printWidth": 120
|
|
53
|
-
}
|
|
54
|
-
],
|
|
55
|
-
"no-unused-vars": [
|
|
56
|
-
"error",
|
|
57
|
-
{
|
|
58
|
-
"vars": "all",
|
|
59
|
-
"args": "none"
|
|
60
|
-
}
|
|
61
|
-
],
|
|
62
|
-
"semi": [
|
|
63
|
-
"error",
|
|
64
|
-
"always"
|
|
65
|
-
],
|
|
66
|
-
"curly": "error",
|
|
67
|
-
"eqeqeq": "error",
|
|
68
|
-
"no-eval": "error",
|
|
69
|
-
"no-loop-func": "error",
|
|
70
|
-
"radix": "error",
|
|
71
|
-
"comma-dangle": "error",
|
|
72
|
-
"no-undef": "error"
|
|
73
|
-
}
|
|
74
|
-
},
|
|
75
|
-
"prettier": {
|
|
76
|
-
"printWidth": 120,
|
|
77
|
-
"tabWidth": 4,
|
|
78
|
-
"useTabs": false,
|
|
79
|
-
"semi": true,
|
|
80
|
-
"singleQuote": true,
|
|
81
|
-
"trailingComma": "none"
|
|
44
|
+
"packages/php-injector": {
|
|
45
|
+
"url": "https://github.com/bylexus/php-injector/archive/0.0.8.tar.gz",
|
|
46
|
+
"strip": 1
|
|
82
47
|
}
|
|
48
|
+
}
|
|
83
49
|
}
|