tar-dependency 0.0.3 → 0.2.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 ADDED
@@ -0,0 +1 @@
1
+ 20
package/README.md CHANGED
@@ -1,26 +1,27 @@
1
- tar-dependency
2
- ======================
1
+ # tar-dependency
3
2
 
4
3
  > Installs tar archives defined in package.json to a directory
5
4
 
6
- This small command line tool has the following purpose:
5
+ This is a small helper tool with the following purpose:
7
6
 
8
7
  * It fetches / extracts .tar(.gz) archives into a local folder
9
8
  * It stores the installed archive infos in `package.json`
10
9
 
11
- This tool is mainly used during development: The archives needed during development / as part of the package can
10
+ This tool is mainly used for fetching git repositories as tar archives from github / gitlab: The archives needed during development / as part of the package can
12
11
  be defined in `package.json`, so this information is part of the main repo and can be distributed to source control.
13
- It allows adding non-git / non-npm dependencies to be installed as part of the package management.
12
+ It allows adding non-npm dependencies to be installed as part of the package management.
14
13
 
15
- We created this tool to replace [Bower](https://bower.io/), where cannot use npm/yarn for non-JS/Web repositories.
14
+ We created this tool to replace [Bower](https://bower.io/), where packages are not available as npm/yarn packages.
16
15
 
17
- Installation
18
- -------------
16
+ ## Requirements
17
+
18
+ This library needs at least NodeJS >= 20
19
+
20
+ ## Installation
19
21
 
20
22
  `npm install --save-dev tar-dependency`
21
23
 
22
- Usage
23
- -----
24
+ ## Usage
24
25
 
25
26
  *Note*: This tool assumes a `package.json` in the current working directory.
26
27
 
@@ -90,6 +91,16 @@ and then install them with
90
91
 
91
92
  `tar-dependency install`
92
93
 
94
+ ## Changelog
95
+
96
+ ### 0.2.0 - Feb 2025
97
+
98
+ * [breaking] Updated to NodeJS >= 20 with ES Modules
99
+ * [breaking] You need a NodeJS version that supports ES Modules (~ V.14.0)
100
+ * Updated dependant packages
101
+
102
+ ### 0.1.0
93
103
 
104
+ Initial release
94
105
 
95
- (c) 2017 alex@alexi.ch
106
+ (c) 2017-2025 alex@alexi.ch
package/bin/cmd.js CHANGED
@@ -4,34 +4,35 @@
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
- var lib = require('../index.js');
11
- var jsonfile = require('jsonfile');
12
- var path = require('path');
13
- var program = require('commander');
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
- var setWorkingDir = function(dir) {
16
+ function setWorkingDir(dir) {
16
17
  process.chdir(dir);
17
- };
18
+ }
18
19
 
19
- var packageConfigPath = function() {
20
+ function packageConfigPath() {
20
21
  return path.join(process.cwd(), 'package.json');
21
- };
22
+ }
22
23
 
23
- var readPackageConfig = function() {
24
+ function readPackageConfig() {
24
25
  return jsonfile.readFileSync(packageConfigPath());
25
- };
26
+ }
26
27
 
27
- var packageConf = readPackageConfig();
28
+ const packageConf = readPackageConfig();
28
29
 
29
30
  program.option('-w, --working-dir <path>', 'use specified working directory');
30
31
 
31
32
  program
32
33
  .command('install')
33
34
  .description('installs / updates tar dependencies defined in package.json')
34
- .action(function() {
35
+ .action(async function () {
35
36
  setWorkingDir(this.parent.workingDir || process.cwd());
36
37
  lib.install(packageConf);
37
38
  });
@@ -45,12 +46,12 @@ program
45
46
  .description(
46
47
  'Fetches the tar from <url> and extracts it to <dest-dir>. Note that dest-dir SHOULD be relative to package.json. Updates package.json.'
47
48
  )
48
- .action(function(url, destDir) {
49
+ .action(async function (url, destDir) {
49
50
  var strip = this.strip === undefined ? 1 : Number(this.strip);
50
51
  setWorkingDir(this.parent.workingDir || process.cwd());
51
52
  lib.add(packageConf, url, destDir, strip);
52
53
  lib.saveConfig(packageConf, packageConfigPath());
53
- lib.install(packageConf, destDir);
54
+ await lib.install(packageConf, destDir);
54
55
  });
55
56
 
56
57
  program
@@ -58,14 +59,16 @@ program
58
59
  .description(
59
60
  'Removes an installed/extracted archive from disk as well as from package.json. Please make sure dest-dir identifies an entry in package.json.'
60
61
  )
61
- .action(function(name) {
62
+ .action(async function (name) {
62
63
  setWorkingDir(this.parent.workingDir || process.cwd());
63
64
  lib.remove(packageConf, name);
64
65
  lib.saveConfig(packageConf, packageConfigPath());
65
66
  });
66
67
 
67
- program.parse(process.argv);
68
+ (async function () {
69
+ await program.parseAsync(process.argv);
68
70
 
69
- if (!process.argv.slice(2).length) {
70
- program.help();
71
- }
71
+ if (!process.argv.slice(2).length) {
72
+ program.help();
73
+ }
74
+ })();
@@ -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,14 +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
- var path = require('path'),
7
- jsonfile = require('jsonfile'),
8
- rimraf = require('rimraf'),
9
- mkdirp = require('mkdirp'),
10
- tar = require('tar'),
11
- request = require('request');
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';
12
14
 
13
15
  function normalizePathKey(str) {
14
16
  return (str || '').replace(/(^\/)|(\/$)/g, ''); // remove leading/trailing slashes)
@@ -27,40 +29,35 @@ function normalizePathKey(str) {
27
29
  * ...
28
30
  * }
29
31
  *
30
- * Note that this function:
31
- * - runs SYNCHRONOUS intentionally
32
+ * This function returns a promise that resolves when all dependencies are installed.
32
33
  */
33
- var installTarDependencies = function(config, destKey) {
34
+ async function installTarDependencies(config, destKey) {
34
35
  config = config || {};
35
- var path = require('path'),
36
- deps = config.tarDependencies || {};
36
+ const deps = config.tarDependencies || {};
37
37
 
38
38
  destKey = normalizePathKey(destKey);
39
- Object.keys(deps).forEach(function(key) {
39
+ for (const key of Object.keys(deps)) {
40
40
  if (destKey && key !== destKey) {
41
41
  return;
42
42
  }
43
- var dest = key;
44
- var fullOutdir = path.join(process.cwd(), dest);
45
- var url = deps[key].url;
46
- var strip = deps[key].strip;
43
+ const fullOutdir = path.join(process.cwd(), key);
44
+ const url = deps[key].url;
45
+ const strip = deps[key].strip === undefined ? 1 : Number(deps[key].strip);
47
46
 
48
- if (strip === undefined) {
49
- strip = 1;
50
- }
51
- console.log('tar package: ' + url + ' => ' + dest);
52
- rimraf.sync(fullOutdir);
53
- mkdirp.sync(fullOutdir);
47
+ console.log('tar package: ' + url + ' => ' + key);
48
+ await rimraf(fullOutdir);
49
+ await mkdirp(fullOutdir);
54
50
 
55
- request(url).pipe(
51
+ const response = await fetch(url);
52
+ response.body.pipe(
56
53
  tar.x({
57
54
  strip: strip,
58
55
  C: fullOutdir,
59
56
  sync: true
60
57
  })
61
58
  );
62
- });
63
- };
59
+ }
60
+ }
64
61
 
65
62
  /*
66
63
  * Adds an archive to the list of dependencies, but does NOT install it:
@@ -70,7 +67,7 @@ var installTarDependencies = function(config, destKey) {
70
67
  *
71
68
  * The given config object is updated.
72
69
  */
73
- var addArchive = function(config, url, destDir, strip) {
70
+ function addArchive(config, url, destDir, strip) {
74
71
  config = config || {};
75
72
  strip = strip === undefined ? 1 : Number(strip);
76
73
  destDir = normalizePathKey(destDir);
@@ -79,7 +76,7 @@ var addArchive = function(config, url, destDir, strip) {
79
76
  tarConfig.url = url;
80
77
  tarConfig.strip = strip;
81
78
  config.tarDependencies[destDir] = tarConfig;
82
- };
79
+ }
83
80
 
84
81
  /*
85
82
  * Removes an archive identified by given path key. It removes the archive on the disk
@@ -90,7 +87,7 @@ var addArchive = function(config, url, destDir, strip) {
90
87
  *
91
88
  * The given config object is updated.
92
89
  */
93
- var removeArchive = function(config, destDir) {
90
+ async function removeArchive(config, destDir) {
94
91
  config = config || {};
95
92
  config.tarDependencies = config.tarDependencies || {};
96
93
  destDir = normalizePathKey(destDir);
@@ -99,10 +96,9 @@ var removeArchive = function(config, destDir) {
99
96
  delete config.tarDependencies[destDir];
100
97
  }
101
98
 
102
- var fullOutdir = path.join(process.cwd(), destDir);
103
-
104
- rimraf.sync(fullOutdir);
105
- };
99
+ const fullOutdir = path.join(process.cwd(), destDir);
100
+ await rimraf(fullOutdir);
101
+ }
106
102
 
107
103
  /*
108
104
  * Saves the given config object as json to a file. Normally, 'file'
@@ -110,12 +106,12 @@ var removeArchive = function(config, destDir) {
110
106
  *
111
107
  * See README.md for more information and examples.
112
108
  */
113
- var saveConf = function(config, file) {
109
+ async function saveConf(config, file) {
114
110
  config = config || {};
115
- jsonfile.writeFileSync(file, config, { spaces: 2 });
116
- };
111
+ await jsonfile.writeFile(file, config, { spaces: 2 });
112
+ }
117
113
 
118
- module.exports = {
114
+ export default {
119
115
  install: installTarDependencies,
120
116
  add: addArchive,
121
117
  remove: removeArchive,
package/package.json CHANGED
@@ -1,67 +1,49 @@
1
1
  {
2
- "name": "tar-dependency",
3
- "version": "0.0.3",
4
- "description": "Fetches .tar(.gz) archives defined in package.json and extracts them to a specific location.",
5
- "main": "index.js",
6
- "scripts": {
7
- "test": "echo \"Error: no test specified\" && exit 1"
2
+ "name": "tar-dependency",
3
+ "version": "0.2.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.1.0",
16
+ "mkdirp": "^3.0.1",
17
+ "node-fetch": "^2.6.5",
18
+ "rimraf": "^6.0.1",
19
+ "tar": "^7.4.3"
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
- "author": "Alexander Schenkel",
10
- "email": "alex@alexi.ch",
11
- "license": "MIT",
12
- "dependencies": {
13
- "commander": "^2.11.0",
14
- "jsonfile": "^4.0.0",
15
- "mkdirp": "^0.5.1",
16
- "request": "^2.83.0",
17
- "rimraf": "^2.6.2",
18
- "tar": "^4.0.2"
19
- },
20
- "devDependencies": {
21
- "eslint": "^4.11.0",
22
- "eslint-config-prettier": "^2.8.0",
23
- "eslint-plugin-prettier": "^2.3.1",
24
- "prettier": "^1.8.2"
25
- },
26
- "bin": {
27
- "tar-dependency": "bin/cmd.js"
28
- },
29
- "eslintConfig": {
30
- "root": true,
31
- "extends": "prettier",
32
- "env": {
33
- "node": true
34
- },
35
- "plugins": [
36
- "prettier"
37
- ],
38
- "rules": {
39
- "prettier/prettier": [
40
- "error",
41
- {
42
- "singleQuote": true,
43
- "tabWidth": 4,
44
- "printWidth": 120
45
- }
46
- ],
47
- "no-unused-vars": [
48
- "error",
49
- {
50
- "vars": "all",
51
- "args": "none"
52
- }
53
- ],
54
- "semi": [
55
- "error",
56
- "always"
57
- ],
58
- "curly": "error",
59
- "eqeqeq": "error",
60
- "no-eval": "error",
61
- "no-loop-func": "error",
62
- "radix": "error",
63
- "comma-dangle": "error",
64
- "no-undef": "error"
65
- }
44
+ "packages/php-injector": {
45
+ "url": "https://github.com/bylexus/php-injector/archive/0.0.8.tar.gz",
46
+ "strip": 1
66
47
  }
48
+ }
67
49
  }