@adeficior/data-modifier-loader 0.0.0 → 2.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/dist/index.d.ts +5 -0
- package/dist/index.js +61 -0
- package/dist/index.js.map +1 -0
- package/package.json +25 -7
- package/README.md +0 -45
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import type { ModuleConfig } from "@adeficior/data-modifier-core";
|
|
2
|
+
export declare function findModuleIn(dir: string): Promise<ModuleConfig>;
|
|
3
|
+
export declare function readModule(file: string): Promise<ModuleConfig>;
|
|
4
|
+
export declare function loadDependencyModules(dependencies: ModuleConfig["dependencies"], root?: string): Promise<ModuleConfig[]>;
|
|
5
|
+
export declare function loadModules(names: string[]): Promise<ModuleConfig[]>;
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
import { uniqBy } from "lodash-es";
|
|
2
|
+
import { exists } from "node:fs/promises";
|
|
3
|
+
import { join, relative, resolve } from "node:path";
|
|
4
|
+
export async function findModuleIn(dir) {
|
|
5
|
+
const candidates = [
|
|
6
|
+
join(dir, "src", "module.ts"),
|
|
7
|
+
join(dir, "dist", "module.js"),
|
|
8
|
+
];
|
|
9
|
+
const match = (await Promise.all(candidates.map((it) => exists(it)))).findIndex((it) => it);
|
|
10
|
+
if (match < 0) {
|
|
11
|
+
throw new Error(`could not find module in ${resolve(dir)}`);
|
|
12
|
+
}
|
|
13
|
+
return readModule(candidates[match]);
|
|
14
|
+
}
|
|
15
|
+
export async function readModule(file) {
|
|
16
|
+
const url = relative(import.meta.dirname, file);
|
|
17
|
+
const exports = await import(url);
|
|
18
|
+
return exports.default;
|
|
19
|
+
}
|
|
20
|
+
function resolveModuleIn(...folders) {
|
|
21
|
+
return async (name) => {
|
|
22
|
+
const candidates = folders.map((nodeModules) => join(nodeModules, name));
|
|
23
|
+
for (const candidate of candidates) {
|
|
24
|
+
if (await exists(candidate)) {
|
|
25
|
+
return candidate;
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
throw new Error("module does not exist in any folder");
|
|
29
|
+
};
|
|
30
|
+
}
|
|
31
|
+
async function loadDependencyModulesRecursive(nodeModules, dependencies, exclude) {
|
|
32
|
+
const found = await Promise.all(Object.entries(dependencies).map(async ([name, type]) => {
|
|
33
|
+
const strategy = resolveModuleIn(...nodeModules);
|
|
34
|
+
const dependencyDir = await strategy(name);
|
|
35
|
+
const dependencyModule = await findModuleIn(dependencyDir);
|
|
36
|
+
if (exclude.includes(name))
|
|
37
|
+
return [];
|
|
38
|
+
if (dependencyModule) {
|
|
39
|
+
return [
|
|
40
|
+
dependencyModule,
|
|
41
|
+
...(await loadDependencyModulesRecursive([...nodeModules, join(dependencyDir, "node_modules")], dependencyModule.dependencies, [...exclude, name])),
|
|
42
|
+
];
|
|
43
|
+
}
|
|
44
|
+
const message = `missing ${type} dependency module '${name}'`;
|
|
45
|
+
if (type === "required")
|
|
46
|
+
throw new Error(message);
|
|
47
|
+
return [];
|
|
48
|
+
}));
|
|
49
|
+
return uniqBy(found.flat(), (it) => it.name);
|
|
50
|
+
}
|
|
51
|
+
export function loadDependencyModules(dependencies, root = ".") {
|
|
52
|
+
return loadDependencyModulesRecursive([join(root, "node_modules")], dependencies, []);
|
|
53
|
+
}
|
|
54
|
+
export function loadModules(names) {
|
|
55
|
+
const dependencies = Object.fromEntries(names.map((it) => [it, "required"]));
|
|
56
|
+
return loadDependencyModules({
|
|
57
|
+
"@adeficior/data-modifier": "required",
|
|
58
|
+
...dependencies,
|
|
59
|
+
});
|
|
60
|
+
}
|
|
61
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,MAAM,EAAE,MAAM,WAAW,CAAC;AACnC,OAAO,EAAE,MAAM,EAAE,MAAM,kBAAkB,CAAC;AAC1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C;AAED,MAAM,UAAU,qBAAqB,CACnC,YAA0C,EAC1C,OAAe,GAAG;IAElB,OAAO,8BAA8B,CACnC,CAAC,IAAI,CAAC,IAAI,EAAE,cAAc,CAAC,CAAC,EAC5B,YAAY,EACZ,EAAE,CACH,CAAC;AACJ,CAAC;AAED,MAAM,UAAU,WAAW,CAAC,KAAe;IACzC,MAAM,YAAY,GAAiC,MAAM,CAAC,WAAW,CACnE,KAAK,CAAC,GAAG,CAAC,CAAC,EAAE,EAAE,EAAE,CAAC,CAAC,EAAE,EAAE,UAAU,CAAC,CAAC,CACpC,CAAC;IAEF,OAAO,qBAAqB,CAAC;QAC3B,0BAA0B,EAAE,UAAU;QACtC,GAAG,YAAY;KAChB,CAAC,CAAC;AACL,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,10 +1,28 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@adeficior/data-modifier-loader",
|
|
3
|
-
"
|
|
4
|
-
"
|
|
5
|
-
"
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
"
|
|
9
|
-
|
|
3
|
+
"description": "module loading logic",
|
|
4
|
+
"version": "2.0.0",
|
|
5
|
+
"exports": { ".": "./dist/index.js" },
|
|
6
|
+
"type": "module",
|
|
7
|
+
"devDependencies": {
|
|
8
|
+
"@adeficior/data-modifier-core": "^2.0.0",
|
|
9
|
+
"@types/lodash-es": "^4.17.12"
|
|
10
|
+
},
|
|
11
|
+
"peerDependencies": {
|
|
12
|
+
"typescript": "^5",
|
|
13
|
+
"lodash-es": "^4.18.1",
|
|
14
|
+
"@adeficior/data-modifier-core": "^2.0.0"
|
|
15
|
+
},
|
|
16
|
+
"typesVersions": { "*": {} },
|
|
17
|
+
"types": "./dist/index.d.ts",
|
|
18
|
+
"files": ["dist"],
|
|
19
|
+
"bugs": { "url": "https://github.com/Adeficior/DataModifier/issues" },
|
|
20
|
+
"homepage": "https://github.com/Adeficior/DataModifier#readme",
|
|
21
|
+
"license": "LGPL-3.0-or-later",
|
|
22
|
+
"repository": {
|
|
23
|
+
"type": "git",
|
|
24
|
+
"url": "git+https://github.com/Adeficior/DataModifier.git",
|
|
25
|
+
"directory": "packages/loader"
|
|
26
|
+
},
|
|
27
|
+
"publishConfig": { "provenance": true }
|
|
10
28
|
}
|
package/README.md
DELETED
|
@@ -1,45 +0,0 @@
|
|
|
1
|
-
# @adeficior/data-modifier-loader
|
|
2
|
-
|
|
3
|
-
## ⚠️ IMPORTANT NOTICE ⚠️
|
|
4
|
-
|
|
5
|
-
**This package is created solely for the purpose of setting up OIDC (OpenID Connect) trusted publishing with npm.**
|
|
6
|
-
|
|
7
|
-
This is **NOT** a functional package and contains **NO** code or functionality beyond the OIDC setup configuration.
|
|
8
|
-
|
|
9
|
-
## Purpose
|
|
10
|
-
|
|
11
|
-
This package exists to:
|
|
12
|
-
1. Configure OIDC trusted publishing for the package name `@adeficior/data-modifier-loader`
|
|
13
|
-
2. Enable secure, token-less publishing from CI/CD workflows
|
|
14
|
-
3. Establish provenance for packages published under this name
|
|
15
|
-
|
|
16
|
-
## What is OIDC Trusted Publishing?
|
|
17
|
-
|
|
18
|
-
OIDC trusted publishing allows package maintainers to publish packages directly from their CI/CD workflows without needing to manage npm access tokens. Instead, it uses OpenID Connect to establish trust between the CI/CD provider (like GitHub Actions) and npm.
|
|
19
|
-
|
|
20
|
-
## Setup Instructions
|
|
21
|
-
|
|
22
|
-
To properly configure OIDC trusted publishing for this package:
|
|
23
|
-
|
|
24
|
-
1. Go to [npmjs.com](https://www.npmjs.com/) and navigate to your package settings
|
|
25
|
-
2. Configure the trusted publisher (e.g., GitHub Actions)
|
|
26
|
-
3. Specify the repository and workflow that should be allowed to publish
|
|
27
|
-
4. Use the configured workflow to publish your actual package
|
|
28
|
-
|
|
29
|
-
## DO NOT USE THIS PACKAGE
|
|
30
|
-
|
|
31
|
-
This package is a placeholder for OIDC configuration only. It:
|
|
32
|
-
- Contains no executable code
|
|
33
|
-
- Provides no functionality
|
|
34
|
-
- Should not be installed as a dependency
|
|
35
|
-
- Exists only for administrative purposes
|
|
36
|
-
|
|
37
|
-
## More Information
|
|
38
|
-
|
|
39
|
-
For more details about npm's trusted publishing feature, see:
|
|
40
|
-
- [npm Trusted Publishing Documentation](https://docs.npmjs.com/generating-provenance-statements)
|
|
41
|
-
- [GitHub Actions OIDC Documentation](https://docs.github.com/en/actions/deployment/security-hardening-your-deployments/about-security-hardening-with-openid-connect)
|
|
42
|
-
|
|
43
|
-
---
|
|
44
|
-
|
|
45
|
-
**Maintained for OIDC setup purposes only**
|