@dependency-owners/pubspec-loader 1.0.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/LICENSE +28 -0
- package/README.md +3 -0
- package/dist/index.d.ts +13 -0
- package/dist/index.js +27 -0
- package/package.json +64 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
BSD 3-Clause License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2025 Kirk Eaton
|
|
4
|
+
|
|
5
|
+
Redistribution and use in source and binary forms, with or without
|
|
6
|
+
modification, are permitted provided that the following conditions are met:
|
|
7
|
+
|
|
8
|
+
1. Redistributions of source code must retain the above copyright notice, this
|
|
9
|
+
list of conditions and the following disclaimer.
|
|
10
|
+
|
|
11
|
+
2. Redistributions in binary form must reproduce the above copyright notice,
|
|
12
|
+
this list of conditions and the following disclaimer in the documentation
|
|
13
|
+
and/or other materials provided with the distribution.
|
|
14
|
+
|
|
15
|
+
3. Neither the name of the copyright holder nor the names of its
|
|
16
|
+
contributors may be used to endorse or promote products derived from
|
|
17
|
+
this software without specific prior written permission.
|
|
18
|
+
|
|
19
|
+
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
|
20
|
+
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
|
21
|
+
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
|
22
|
+
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
|
|
23
|
+
FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
|
24
|
+
DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
|
|
25
|
+
SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
|
26
|
+
CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
|
|
27
|
+
OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
|
28
|
+
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
package/README.md
ADDED
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import type { Dependency } from 'dependency-owners/loader';
|
|
2
|
+
/**
|
|
3
|
+
* Check if the loader can handle the specified file.
|
|
4
|
+
* @param {string} filePath The path of the file to check.
|
|
5
|
+
* @returns {Promise<boolean>} True if the file can be loaded, false otherwise.
|
|
6
|
+
*/
|
|
7
|
+
export declare const canLoad: (filePath: string) => Promise<boolean>;
|
|
8
|
+
/**
|
|
9
|
+
* Loads the pubspec.yaml file and returns its dependencies.
|
|
10
|
+
* @param {string} filePath The path of the pubspec.yaml file to load.
|
|
11
|
+
* @returns {Promise<Dependency[]>} An array of dependencies.
|
|
12
|
+
*/
|
|
13
|
+
export declare const load: (filePath: string) => Promise<Dependency[]>;
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import fs from 'node:fs/promises';
|
|
2
|
+
import path from 'node:path';
|
|
3
|
+
import { parse } from 'yaml';
|
|
4
|
+
const mapDependency = ([name, version]) => ({
|
|
5
|
+
name,
|
|
6
|
+
version: String(version),
|
|
7
|
+
});
|
|
8
|
+
/**
|
|
9
|
+
* Check if the loader can handle the specified file.
|
|
10
|
+
* @param {string} filePath The path of the file to check.
|
|
11
|
+
* @returns {Promise<boolean>} True if the file can be loaded, false otherwise.
|
|
12
|
+
*/
|
|
13
|
+
export const canLoad = async function (filePath) {
|
|
14
|
+
return path.basename(filePath) === 'pubspec.yaml';
|
|
15
|
+
};
|
|
16
|
+
/**
|
|
17
|
+
* Loads the pubspec.yaml file and returns its dependencies.
|
|
18
|
+
* @param {string} filePath The path of the pubspec.yaml file to load.
|
|
19
|
+
* @returns {Promise<Dependency[]>} An array of dependencies.
|
|
20
|
+
*/
|
|
21
|
+
export const load = async function (filePath) {
|
|
22
|
+
const pubspec = parse(await fs.readFile(filePath, 'utf-8'));
|
|
23
|
+
return [
|
|
24
|
+
...Object.entries(pubspec.dependencies || {}).map(mapDependency),
|
|
25
|
+
...Object.entries(pubspec.dev_dependencies || {}).map(mapDependency),
|
|
26
|
+
];
|
|
27
|
+
};
|
package/package.json
ADDED
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@dependency-owners/pubspec-loader",
|
|
3
|
+
"version": "1.0.0",
|
|
4
|
+
"description": "dependency-owners loader for pubspec.yaml files",
|
|
5
|
+
"author": "Kirk Eaton <contact@kirkeaton.ca>",
|
|
6
|
+
"bugs": {
|
|
7
|
+
"url": "https://github.com/dependency-owners/pubspec-loader/issues"
|
|
8
|
+
},
|
|
9
|
+
"dependencies": {
|
|
10
|
+
"yaml": "2.8.1"
|
|
11
|
+
},
|
|
12
|
+
"devDependencies": {
|
|
13
|
+
"@kirkeaton/prettier-config": "1.0.5",
|
|
14
|
+
"@kirkeaton/semantic-release-config": "1.1.0",
|
|
15
|
+
"@kirkeaton/tsconfig": "2.1.0",
|
|
16
|
+
"@types/node": "24.3.0",
|
|
17
|
+
"dependency-owners": "3.0.0",
|
|
18
|
+
"fs-fixture": "2.8.1",
|
|
19
|
+
"prettier": "3.6.2",
|
|
20
|
+
"semantic-release": "24.2.7",
|
|
21
|
+
"typescript": "5.9.2"
|
|
22
|
+
},
|
|
23
|
+
"engines": {
|
|
24
|
+
"node": ">=20"
|
|
25
|
+
},
|
|
26
|
+
"exports": {
|
|
27
|
+
"types": "./dist/index.d.ts",
|
|
28
|
+
"default": "./dist/index.js"
|
|
29
|
+
},
|
|
30
|
+
"files": [
|
|
31
|
+
"dist"
|
|
32
|
+
],
|
|
33
|
+
"funding": "https://kirkeaton.ca/sponsor",
|
|
34
|
+
"homepage": "https://github.com/dependency-owners/pubspec-loader#readme",
|
|
35
|
+
"keywords": [
|
|
36
|
+
"dependency",
|
|
37
|
+
"owners",
|
|
38
|
+
"pubspec",
|
|
39
|
+
"yaml",
|
|
40
|
+
"loader"
|
|
41
|
+
],
|
|
42
|
+
"license": "BSD-3-Clause",
|
|
43
|
+
"packageManager": "pnpm@10.15.0",
|
|
44
|
+
"peerDependencies": {
|
|
45
|
+
"dependency-owners": ">=1.2.1"
|
|
46
|
+
},
|
|
47
|
+
"publishConfig": {
|
|
48
|
+
"access": "public"
|
|
49
|
+
},
|
|
50
|
+
"repository": {
|
|
51
|
+
"type": "git",
|
|
52
|
+
"url": "git+https://github.com/dependency-owners/pubspec-loader.git"
|
|
53
|
+
},
|
|
54
|
+
"scripts": {
|
|
55
|
+
"build": "pnpm clean && tsc",
|
|
56
|
+
"clean": "rm -rf dist",
|
|
57
|
+
"format": "prettier \"**/*.{js,json,md,ts}\" --write",
|
|
58
|
+
"lint": "prettier \"**/*.{js,json,md,ts}\" --check",
|
|
59
|
+
"prepublishOnly": "pnpm build",
|
|
60
|
+
"test": "node --test",
|
|
61
|
+
"typecheck": "tsc --noEmit"
|
|
62
|
+
},
|
|
63
|
+
"type": "module"
|
|
64
|
+
}
|