ts-ag 1.0.0 → 1.0.2
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/dist/utils/fs.d.ts +5 -0
- package/dist/utils/fs.d.ts.map +1 -1
- package/dist/utils/fs.js +8 -0
- package/package.json +5 -3
- package/src/utils/fs.ts +9 -0
package/dist/utils/fs.d.ts
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import type { PackageJson } from 'type-fest';
|
|
1
2
|
/**
|
|
2
3
|
* @returns true if a filepath exists
|
|
3
4
|
*/
|
|
@@ -7,4 +8,8 @@ export declare function exists(filePath: string): Promise<boolean>;
|
|
|
7
8
|
* @returns true if the file is written to
|
|
8
9
|
*/
|
|
9
10
|
export declare function writeIfDifferent(filePath: string, newData: string): Promise<boolean>;
|
|
11
|
+
/**
|
|
12
|
+
* @returns the json object packageJson or undefined if it doesnt exist
|
|
13
|
+
*/
|
|
14
|
+
export declare function readPackageJson(filePath: string): Promise<PackageJson | undefined>;
|
|
10
15
|
//# sourceMappingURL=fs.d.ts.map
|
package/dist/utils/fs.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"fs.d.ts","sourceRoot":"","sources":["../../src/utils/fs.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"fs.d.ts","sourceRoot":"","sources":["../../src/utils/fs.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,WAAW,CAAC;AAE7C;;GAEG;AACH,wBAAsB,MAAM,CAAC,QAAQ,EAAE,MAAM,GAAG,OAAO,CAAC,OAAO,CAAC,CAO/D;AAED;;;GAGG;AACH,wBAAsB,gBAAgB,CAAC,QAAQ,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,GAAG,OAAO,CAAC,OAAO,CAAC,CAuB1F;AAED;;GAEG;AACH,wBAAsB,eAAe,CAAC,QAAQ,EAAE,MAAM,GAAG,OAAO,CAAC,WAAW,GAAG,SAAS,CAAC,CAGxF"}
|
package/dist/utils/fs.js
CHANGED
|
@@ -38,3 +38,11 @@ export async function writeIfDifferent(filePath, newData) {
|
|
|
38
38
|
console.log(chalk.green('Writing to'), filePath);
|
|
39
39
|
return true;
|
|
40
40
|
}
|
|
41
|
+
/**
|
|
42
|
+
* @returns the json object packageJson or undefined if it doesnt exist
|
|
43
|
+
*/
|
|
44
|
+
export async function readPackageJson(filePath) {
|
|
45
|
+
if (!(await exists(filePath)))
|
|
46
|
+
return undefined;
|
|
47
|
+
return JSON.parse(await readFile(filePath, { encoding: 'utf-8' }));
|
|
48
|
+
}
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "ts-ag",
|
|
3
3
|
"description": "Useful TS stuff",
|
|
4
|
-
"version": "1.0.
|
|
4
|
+
"version": "1.0.2",
|
|
5
5
|
"author": "Alexander Hornung",
|
|
6
6
|
"bugs": "https://github.com/ageorgeh/ts-ag/issues",
|
|
7
7
|
"bin": {
|
|
@@ -27,7 +27,8 @@
|
|
|
27
27
|
"chalk": "5.6.0",
|
|
28
28
|
"neverthrow": "8.2.0",
|
|
29
29
|
"tsconfck": "3.1.6",
|
|
30
|
-
"devalue": "5.1.1"
|
|
30
|
+
"devalue": "5.1.1",
|
|
31
|
+
"type-fest": "5.1.0"
|
|
31
32
|
},
|
|
32
33
|
"peerDependencies": {},
|
|
33
34
|
"devDependencies": {
|
|
@@ -73,6 +74,7 @@
|
|
|
73
74
|
"publish:local": "pnpm version prerelease --preid dev --no-git-tag-version && pnpm publish --registry http://localhost:4873 --tag dev --access public --no-git-checks --json > ./publishLocal.json",
|
|
74
75
|
"publish:prerelease": "pnpm publish --tag dev --access public --no-git-checks --registry=https://registry.npmjs.org/ --json > ./publish.json",
|
|
75
76
|
"version:prerelease": "pnpm version prerelease --preid dev --no-git-tag-version",
|
|
76
|
-
"
|
|
77
|
+
"run-publish": "pnpm publish --access public --no-git-checks --registry=https://registry.npmjs.org/ --json > ./publish.json",
|
|
78
|
+
"run-version": "pnpm version --no-git-tag-version"
|
|
77
79
|
}
|
|
78
80
|
}
|
package/src/utils/fs.ts
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { lstat, mkdir, readFile, writeFile } from 'fs/promises';
|
|
2
2
|
import { dirname } from 'path';
|
|
3
3
|
import chalk from 'chalk';
|
|
4
|
+
import type { PackageJson } from 'type-fest';
|
|
4
5
|
|
|
5
6
|
/**
|
|
6
7
|
* @returns true if a filepath exists
|
|
@@ -42,3 +43,11 @@ export async function writeIfDifferent(filePath: string, newData: string): Promi
|
|
|
42
43
|
console.log(chalk.green('Writing to'), filePath);
|
|
43
44
|
return true;
|
|
44
45
|
}
|
|
46
|
+
|
|
47
|
+
/**
|
|
48
|
+
* @returns the json object packageJson or undefined if it doesnt exist
|
|
49
|
+
*/
|
|
50
|
+
export async function readPackageJson(filePath: string): Promise<PackageJson | undefined> {
|
|
51
|
+
if (!(await exists(filePath))) return undefined;
|
|
52
|
+
return JSON.parse(await readFile(filePath, { encoding: 'utf-8' })) as PackageJson;
|
|
53
|
+
}
|