copy-file-util 1.1.1 → 1.1.3
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/LICENSE.txt +1 -1
- package/README.md +7 -2
- package/bin/cli.js +2 -14
- package/dist/copy-file.d.ts +4 -3
- package/dist/copy-file.js +12 -1
- package/package.json +12 -9
package/LICENSE.txt
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
MIT License
|
|
2
2
|
|
|
3
|
-
Copyright (c) 2022-
|
|
3
|
+
Copyright (c) 2022-2024 Individual contributors to copy-file-util
|
|
4
4
|
|
|
5
5
|
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
6
|
of this software and associated documentation files (the "Software"), to deal
|
package/README.md
CHANGED
|
@@ -60,9 +60,14 @@ Examples:
|
|
|
60
60
|
- `copy-file app.js --folder dist`<br>
|
|
61
61
|
Copies **app.js** into the **dist** folder.
|
|
62
62
|
|
|
63
|
+
- `copy-file 'src/Legal Notice.md' --folder dist`<br>
|
|
64
|
+
Copies a file that has a space in its filename.
|
|
65
|
+
|
|
63
66
|
- `copy-file app.js --move --folder dist`<br>
|
|
64
67
|
Like the `mv` Unix command.
|
|
65
68
|
|
|
69
|
+
_**Note:** Single quotes in commands are normalized so they work cross-platform and avoid the errors often encountered on Microsoft Windows._
|
|
70
|
+
|
|
66
71
|
### 4. Template variables
|
|
67
72
|
The *target* parameter can contain template variables, like `{{pkg.version}}` and `{{pkg.name}}`, which will be replaced with values with values from your project's **package.json** file.
|
|
68
73
|
|
|
@@ -71,7 +76,7 @@ Example:
|
|
|
71
76
|
Creates a copy of **app.js** named something like **app-v1.2.3.js** based on the version of your project.
|
|
72
77
|
|
|
73
78
|
## C) Application Code
|
|
74
|
-
Even though **copy-file-util** is primarily intended for build scripts, the package can
|
|
79
|
+
Even though **copy-file-util** is primarily intended for build scripts, the package can be used programmatically in ESM and TypeScript projects.
|
|
75
80
|
|
|
76
81
|
Example:
|
|
77
82
|
``` typescript
|
|
@@ -86,7 +91,7 @@ See the **TypeScript Declarations** at the top of [copy-file.ts](copy-file.ts) f
|
|
|
86
91
|
<br>
|
|
87
92
|
|
|
88
93
|
---
|
|
89
|
-
**CLI Build Tools**
|
|
94
|
+
**CLI Build Tools for package.json**
|
|
90
95
|
- 🎋 [add-dist-header](https://github.com/center-key/add-dist-header): _Prepend a one-line banner comment (with license notice) to distribution files_
|
|
91
96
|
- 📄 [copy-file-util](https://github.com/center-key/copy-file-util): _Copy or rename a file with optional package version number_
|
|
92
97
|
- 📂 [copy-folder-util](https://github.com/center-key/copy-folder-util): _Recursively copy files from one folder to another folder_
|
package/bin/cli.js
CHANGED
|
@@ -24,9 +24,7 @@
|
|
|
24
24
|
import { cliArgvUtil } from 'cli-argv-util';
|
|
25
25
|
import { copyFile } from '../dist/copy-file.js';
|
|
26
26
|
import { dna } from 'dna-engine';
|
|
27
|
-
import
|
|
28
|
-
import fs from 'fs';
|
|
29
|
-
import log from 'fancy-log';
|
|
27
|
+
import fs from 'fs';
|
|
30
28
|
|
|
31
29
|
// Parameters and flags
|
|
32
30
|
const validFlags = ['cd', 'folder', 'move', 'note', 'quiet'];
|
|
@@ -39,16 +37,6 @@ const readPackage = () => JSON.parse(fs.readFileSync('package.json', 'utf-8'));
|
|
|
39
37
|
const getPackageField = (match) =>
|
|
40
38
|
dna.util.value({ pkg: readPackage() }, match.replace(/[{}]/g, '')) ?? 'MISSING-FIELD-ERROR';
|
|
41
39
|
|
|
42
|
-
// Reporting
|
|
43
|
-
const printReport = (result) => {
|
|
44
|
-
const name = chalk.gray('copy-file');
|
|
45
|
-
const origin = chalk.blue.bold(result.origin);
|
|
46
|
-
const dest = chalk.magenta(result.dest);
|
|
47
|
-
const arrow = chalk.gray.bold('→');
|
|
48
|
-
const info = chalk.white(`(${result.duration}ms${result.moved ? ', move' : ''})`);
|
|
49
|
-
log(name, origin, arrow, dest, info);
|
|
50
|
-
};
|
|
51
|
-
|
|
52
40
|
// Copy File
|
|
53
41
|
const error =
|
|
54
42
|
cli.invalidFlag ? cli.invalidFlagMsg :
|
|
@@ -67,4 +55,4 @@ const options = {
|
|
|
67
55
|
};
|
|
68
56
|
const result = copyFile.cp(source, options);
|
|
69
57
|
if (!cli.flagOn.quiet)
|
|
70
|
-
|
|
58
|
+
copyFile.reporter(result);
|
package/dist/copy-file.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
//! copy-file-util v1.1.
|
|
1
|
+
//! copy-file-util v1.1.3 ~~ https://github.com/center-key/copy-file-util ~~ MIT License
|
|
2
2
|
|
|
3
|
-
export type
|
|
3
|
+
export type Settings = {
|
|
4
4
|
cd: string;
|
|
5
5
|
targetFile: string;
|
|
6
6
|
targetFolder: string;
|
|
@@ -14,6 +14,7 @@ export type Result = {
|
|
|
14
14
|
moved: boolean;
|
|
15
15
|
};
|
|
16
16
|
declare const copyFile: {
|
|
17
|
-
cp(sourceFile: string, options
|
|
17
|
+
cp(sourceFile: string, options?: Partial<Settings>): Result;
|
|
18
|
+
reporter(result: Result): Result;
|
|
18
19
|
};
|
|
19
20
|
export { copyFile };
|
package/dist/copy-file.js
CHANGED
|
@@ -1,6 +1,8 @@
|
|
|
1
|
-
//! copy-file-util v1.1.
|
|
1
|
+
//! copy-file-util v1.1.3 ~~ https://github.com/center-key/copy-file-util ~~ MIT License
|
|
2
2
|
|
|
3
|
+
import chalk from 'chalk';
|
|
3
4
|
import fs from 'fs';
|
|
5
|
+
import log from 'fancy-log';
|
|
4
6
|
import path from 'path';
|
|
5
7
|
import slash from 'slash';
|
|
6
8
|
const copyFile = {
|
|
@@ -50,5 +52,14 @@ const copyFile = {
|
|
|
50
52
|
duration: Date.now() - startTime,
|
|
51
53
|
};
|
|
52
54
|
},
|
|
55
|
+
reporter(result) {
|
|
56
|
+
const name = chalk.gray('copy-file');
|
|
57
|
+
const origin = chalk.blue.bold(result.origin);
|
|
58
|
+
const dest = chalk.magenta(result.dest);
|
|
59
|
+
const arrow = chalk.gray.bold('→');
|
|
60
|
+
const info = chalk.white(`(${result.duration}ms${result.moved ? ', move' : ''})`);
|
|
61
|
+
log(name, origin, arrow, dest, info);
|
|
62
|
+
return result;
|
|
63
|
+
},
|
|
53
64
|
};
|
|
54
65
|
export { copyFile };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "copy-file-util",
|
|
3
|
-
"version": "1.1.
|
|
3
|
+
"version": "1.1.3",
|
|
4
4
|
"description": "Copy or rename a file with optional package version number (CLI tool designed for use in npm scripts)",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"type": "module",
|
|
@@ -20,7 +20,10 @@
|
|
|
20
20
|
"copy-file": "bin/cli.js",
|
|
21
21
|
"copy-file-util": "bin/cli.js"
|
|
22
22
|
},
|
|
23
|
-
"repository":
|
|
23
|
+
"repository": {
|
|
24
|
+
"type": "git",
|
|
25
|
+
"url": "git+https://github.com/center-key/copy-file-util.git"
|
|
26
|
+
},
|
|
24
27
|
"homepage": "https://github.com/center-key/copy-file-util",
|
|
25
28
|
"bugs": "https://github.com/center-key/copy-file-util/issues",
|
|
26
29
|
"docs": "https://github.com/center-key/copy-file-util#readme",
|
|
@@ -82,22 +85,22 @@
|
|
|
82
85
|
"dependencies": {
|
|
83
86
|
"chalk": "~5.3",
|
|
84
87
|
"cli-argv-util": "~1.2",
|
|
85
|
-
"dna-engine": "~3.
|
|
88
|
+
"dna-engine": "~3.1",
|
|
86
89
|
"fancy-log": "~2.0",
|
|
87
90
|
"slash": "~5.1"
|
|
88
91
|
},
|
|
89
92
|
"devDependencies": {
|
|
90
93
|
"@types/fancy-log": "~2.0",
|
|
91
|
-
"@types/node": "~20.
|
|
92
|
-
"@typescript-eslint/eslint-plugin": "~6.
|
|
93
|
-
"@typescript-eslint/parser": "~6.
|
|
94
|
-
"add-dist-header": "~1.
|
|
94
|
+
"@types/node": "~20.10",
|
|
95
|
+
"@typescript-eslint/eslint-plugin": "~6.17",
|
|
96
|
+
"@typescript-eslint/parser": "~6.17",
|
|
97
|
+
"add-dist-header": "~1.3",
|
|
95
98
|
"assert-deep-strict-equal": "~1.1",
|
|
96
|
-
"eslint": "~8.
|
|
99
|
+
"eslint": "~8.56",
|
|
97
100
|
"jshint": "~2.13",
|
|
98
101
|
"mocha": "~10.2",
|
|
99
102
|
"rimraf": "~5.0",
|
|
100
103
|
"run-scripts-util": "~1.2",
|
|
101
|
-
"typescript": "~5.
|
|
104
|
+
"typescript": "~5.3"
|
|
102
105
|
}
|
|
103
106
|
}
|