prepare-package 0.0.11 → 0.0.14

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/README.md CHANGED
@@ -22,7 +22,7 @@
22
22
  <a href="https://itwcreativeworks.com">Site</a> | <a href="https://www.npmjs.com/package/prepare-package">NPM Module</a> | <a href="https://github.com/itw-creative-works/prepare-package">GitHub Repo</a>
23
23
  <br>
24
24
  <br>
25
- <strong>Prepare Package</strong> is a drop-in replacement NPM module that prepares your package before distribution.
25
+ <strong>Prepare Package</strong> is a helpful NPM module that prepares your package before distribution.
26
26
  </p>
27
27
 
28
28
  ## Install Prepare Package
package/dist/index.js CHANGED
@@ -5,6 +5,11 @@ const chalk = require('chalk');
5
5
  const thisPackageJSON = require('../package.json');
6
6
  const theirPackageJSON = require(path.join(process.cwd(), 'package.json'));
7
7
  const isLivePreparation = theirPackageJSON.name !== 'prepare-package';
8
+ const argv = require('yargs').argv;
9
+
10
+ const options = {
11
+ prepare: argv['--purge'] || argv['-p'],
12
+ };
8
13
 
9
14
  // fix
10
15
  theirPackageJSON.main = theirPackageJSON.main || './dist/index.js';
@@ -41,14 +46,19 @@ if (isLivePreparation) {
41
46
  )
42
47
  }
43
48
 
44
- fetch(`https://purge.jsdelivr.net/npm/${theirPackageJSON.name}@latest`, {
45
- response: 'json',
46
- tries: 3,
47
- })
48
- .then(result => {
49
- // console.log(chalk.green(`[prepare-package]: Purged... name=${theirPackageJSON.name}`), result);
50
- console.log(chalk.green(`[prepare-package]: Purged... ${theirPackageJSON.name}`));
51
- })
52
- .catch(e => {
53
- console.log(chalk.red(`[prepare-package]: Failed to purge... ${theirPackageJSON.name}`, e));
54
- })
49
+ if (options.prepare === 'false') {
50
+ return;
51
+ } else {
52
+ return fetch(`https://purge.jsdelivr.net/npm/${theirPackageJSON.name}@latest`, {
53
+ response: 'json',
54
+ tries: 3,
55
+ })
56
+ .then(result => {
57
+ // console.log(chalk.green(`[prepare-package]: Purged... name=${theirPackageJSON.name}`), result);
58
+ console.log(chalk.green(`[prepare-package]: Purged... ${theirPackageJSON.name}`));
59
+ })
60
+ .catch(e => {
61
+ console.log(chalk.red(`[prepare-package]: Failed to purge... ${theirPackageJSON.name}`, e));
62
+ })
63
+ }
64
+
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "prepare-package",
3
- "version": "0.0.11",
3
+ "version": "0.0.14",
4
4
  "description": "Prepare a Node.js package before being published",
5
5
  "main": "dist/index.js",
6
6
  "scripts": {
@@ -35,9 +35,10 @@
35
35
  "dependencies": {
36
36
  "chalk": "^4.1.2",
37
37
  "fs-jetpack": "^4.3.1",
38
- "wonderful-fetch": "^0.0.11"
38
+ "wonderful-fetch": "^0.0.14",
39
+ "yargs": "^17.5.1"
39
40
  },
40
41
  "devDependencies": {
41
- "mocha": "^8.0.1"
42
+ "mocha": "^8.4.0"
42
43
  }
43
44
  }
package/src/index.js CHANGED
@@ -5,6 +5,11 @@ const chalk = require('chalk');
5
5
  const thisPackageJSON = require('../package.json');
6
6
  const theirPackageJSON = require(path.join(process.cwd(), 'package.json'));
7
7
  const isLivePreparation = theirPackageJSON.name !== 'prepare-package';
8
+ const argv = require('yargs').argv;
9
+
10
+ const options = {
11
+ prepare: argv['--purge'] || argv['-p'],
12
+ };
8
13
 
9
14
  // fix
10
15
  theirPackageJSON.main = theirPackageJSON.main || './dist/index.js';
@@ -41,14 +46,19 @@ if (isLivePreparation) {
41
46
  )
42
47
  }
43
48
 
44
- fetch(`https://purge.jsdelivr.net/npm/${theirPackageJSON.name}@latest`, {
45
- response: 'json',
46
- tries: 3,
47
- })
48
- .then(result => {
49
- // console.log(chalk.green(`[prepare-package]: Purged... name=${theirPackageJSON.name}`), result);
50
- console.log(chalk.green(`[prepare-package]: Purged... ${theirPackageJSON.name}`));
51
- })
52
- .catch(e => {
53
- console.log(chalk.red(`[prepare-package]: Failed to purge... ${theirPackageJSON.name}`, e));
54
- })
49
+ if (options.prepare === 'false') {
50
+ return;
51
+ } else {
52
+ return fetch(`https://purge.jsdelivr.net/npm/${theirPackageJSON.name}@latest`, {
53
+ response: 'json',
54
+ tries: 3,
55
+ })
56
+ .then(result => {
57
+ // console.log(chalk.green(`[prepare-package]: Purged... name=${theirPackageJSON.name}`), result);
58
+ console.log(chalk.green(`[prepare-package]: Purged... ${theirPackageJSON.name}`));
59
+ })
60
+ .catch(e => {
61
+ console.log(chalk.red(`[prepare-package]: Failed to purge... ${theirPackageJSON.name}`, e));
62
+ })
63
+ }
64
+