@atomicsmash/smash-config 0.0.1 → 1.0.0-beta.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 +16 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +1 -0
- package/dist/utils.d.ts +3 -0
- package/dist/utils.d.ts.map +1 -0
- package/dist/utils.js +94 -0
- package/package.json +36 -8
- package/README.md +0 -45
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { Options } from "sass";
|
|
2
|
+
export type SCSSAliases = {
|
|
3
|
+
loadPaths?: Options<"async">["loadPaths"];
|
|
4
|
+
importers?: Options<"async">["importers"];
|
|
5
|
+
};
|
|
6
|
+
export type SmashConfig = {
|
|
7
|
+
projectName: string;
|
|
8
|
+
themePath: string;
|
|
9
|
+
themeFolderName?: string;
|
|
10
|
+
assetsOutputFolder?: string;
|
|
11
|
+
npmInstallPaths?: string[];
|
|
12
|
+
composerInstallPaths?: string[];
|
|
13
|
+
scssAliases?: SCSSAliases;
|
|
14
|
+
};
|
|
15
|
+
export { getSmashConfig } from "./utils.js";
|
|
16
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,MAAM,CAAC;AAE/B,MAAM,MAAM,WAAW,GAAG;IACzB,SAAS,CAAC,EAAE,OAAO,CAAC,OAAO,CAAC,CAAC,WAAW,CAAC,CAAC;IAC1C,SAAS,CAAC,EAAE,OAAO,CAAC,OAAO,CAAC,CAAC,WAAW,CAAC,CAAC;CAC1C,CAAC;AAEF,MAAM,MAAM,WAAW,GAAG;IACzB,WAAW,EAAE,MAAM,CAAC;IACpB,SAAS,EAAE,MAAM,CAAC;IAClB,eAAe,CAAC,EAAE,MAAM,CAAC;IACzB,kBAAkB,CAAC,EAAE,MAAM,CAAC;IAC5B,eAAe,CAAC,EAAE,MAAM,EAAE,CAAC;IAC3B,oBAAoB,CAAC,EAAE,MAAM,EAAE,CAAC;IAChC,WAAW,CAAC,EAAE,WAAW,CAAC;CAC1B,CAAC;AAEF,OAAO,EAAE,cAAc,EAAE,MAAM,YAAY,CAAC"}
|
package/dist/index.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { getSmashConfig } from "./utils.js";
|
package/dist/utils.d.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../src/utils.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAe,WAAW,EAAE,MAAM,YAAY,CAAC;AA4B3D,wBAAsB,cAAc,IAAI,OAAO,CAAC,QAAQ,CAAC,WAAW,CAAC,GAAG,IAAI,CAAC,CAoE5E"}
|
package/dist/utils.js
ADDED
|
@@ -0,0 +1,94 @@
|
|
|
1
|
+
import { normalize, resolve } from "node:path";
|
|
2
|
+
import { pathToFileURL } from "node:url";
|
|
3
|
+
import { cosmiconfig } from "cosmiconfig";
|
|
4
|
+
const getDefaultSCSSAliases = (themePath) => ({
|
|
5
|
+
importers: [
|
|
6
|
+
{
|
|
7
|
+
findFileUrl(url) {
|
|
8
|
+
if (!url.startsWith("sitecss:"))
|
|
9
|
+
return null;
|
|
10
|
+
const pathname = url.substring(8);
|
|
11
|
+
return pathToFileURL(`${resolve(process.cwd(), themePath, "src/styles")}${pathname.startsWith("/") ? pathname : `/${pathname}`}`);
|
|
12
|
+
},
|
|
13
|
+
},
|
|
14
|
+
{
|
|
15
|
+
findFileUrl(url) {
|
|
16
|
+
if (!url.startsWith("launchpad:"))
|
|
17
|
+
return null;
|
|
18
|
+
const pathname = url.substring(10);
|
|
19
|
+
return pathToFileURL(`${resolve(process.cwd(), themePath, "../launchpad/src/styles")}${pathname.startsWith("/") ? pathname : `/${pathname}`}`);
|
|
20
|
+
},
|
|
21
|
+
},
|
|
22
|
+
],
|
|
23
|
+
});
|
|
24
|
+
export async function getSmashConfig() {
|
|
25
|
+
const explorer = cosmiconfig("smash");
|
|
26
|
+
const config = await explorer
|
|
27
|
+
.load(resolve(process.cwd(), "smash.config.ts"))
|
|
28
|
+
.then((result) => {
|
|
29
|
+
if (!result || result.isEmpty) {
|
|
30
|
+
throw new Error("Return default config.");
|
|
31
|
+
}
|
|
32
|
+
const config = result.config;
|
|
33
|
+
if (isValidSmashConfig(config)) {
|
|
34
|
+
const fullConfig = {
|
|
35
|
+
scssAliases: getDefaultSCSSAliases(config.themePath),
|
|
36
|
+
themeFolderName: config.projectName,
|
|
37
|
+
...config,
|
|
38
|
+
// Normalize and resolve paths to cwd.
|
|
39
|
+
npmInstallPaths: config.npmInstallPaths?.map((path) => {
|
|
40
|
+
return normalize(resolve(process.cwd(), path));
|
|
41
|
+
}) ?? [],
|
|
42
|
+
composerInstallPaths: config.composerInstallPaths?.map((path) => {
|
|
43
|
+
return normalize(resolve(process.cwd(), path));
|
|
44
|
+
}) ?? [],
|
|
45
|
+
assetsOutputFolder: config.assetsOutputFolder
|
|
46
|
+
? normalize(config.assetsOutputFolder)
|
|
47
|
+
: "dist",
|
|
48
|
+
};
|
|
49
|
+
return fullConfig;
|
|
50
|
+
}
|
|
51
|
+
throw new Error("Return default config.");
|
|
52
|
+
})
|
|
53
|
+
.catch(async () => {
|
|
54
|
+
const { themeName, themePath } = await import("dotenv")
|
|
55
|
+
.then((dotenv) => {
|
|
56
|
+
dotenv.config();
|
|
57
|
+
const themeName = process.env.THEME_NAME ?? process.env.npm_package_config_theme_name;
|
|
58
|
+
const themePath = process.env.THEME_PATH ?? process.env.npm_package_config_theme_path;
|
|
59
|
+
return {
|
|
60
|
+
themeName,
|
|
61
|
+
themePath,
|
|
62
|
+
};
|
|
63
|
+
})
|
|
64
|
+
.catch(() => {
|
|
65
|
+
return {
|
|
66
|
+
themeName: false,
|
|
67
|
+
themePath: false,
|
|
68
|
+
};
|
|
69
|
+
});
|
|
70
|
+
if (!themeName || !themePath) {
|
|
71
|
+
return null;
|
|
72
|
+
}
|
|
73
|
+
console.warn("Using env vars for theme name and path is deprecated and will be removed in a future version. Create a smash.config.ts file with the relevant properties in it instead.");
|
|
74
|
+
const defaultConfig = {
|
|
75
|
+
projectName: themeName,
|
|
76
|
+
themePath,
|
|
77
|
+
themeFolderName: themeName,
|
|
78
|
+
assetsOutputFolder: "dist",
|
|
79
|
+
npmInstallPaths: [],
|
|
80
|
+
composerInstallPaths: [],
|
|
81
|
+
scssAliases: getDefaultSCSSAliases(themePath),
|
|
82
|
+
};
|
|
83
|
+
return defaultConfig;
|
|
84
|
+
});
|
|
85
|
+
return config;
|
|
86
|
+
}
|
|
87
|
+
function isValidSmashConfig(config) {
|
|
88
|
+
return (typeof config === "object" &&
|
|
89
|
+
config !== null &&
|
|
90
|
+
"projectName" in config &&
|
|
91
|
+
typeof config.projectName === "string" &&
|
|
92
|
+
"themePath" in config &&
|
|
93
|
+
typeof config.themePath === "string");
|
|
94
|
+
}
|
package/package.json
CHANGED
|
@@ -1,10 +1,38 @@
|
|
|
1
1
|
{
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
2
|
+
"name": "@atomicsmash/smash-config",
|
|
3
|
+
"version": "1.0.0-beta.0",
|
|
4
|
+
"description": "",
|
|
5
|
+
"keywords": [],
|
|
6
|
+
"homepage": "https://www.atomicsmash.co.uk/",
|
|
7
|
+
"license": "GPL-3.0-or-later",
|
|
8
|
+
"author": {
|
|
9
|
+
"name": "Atomic Smash",
|
|
10
|
+
"email": "npm@atomicsmash.co.uk",
|
|
11
|
+
"url": "https://www.atomicsmash.co.uk/"
|
|
12
|
+
},
|
|
13
|
+
"repository": {
|
|
14
|
+
"type": "git",
|
|
15
|
+
"url": "https://github.com/AtomicSmash/packages",
|
|
16
|
+
"directory": "packages/smash-config"
|
|
17
|
+
},
|
|
18
|
+
"files": [
|
|
19
|
+
"./dist/**/*"
|
|
20
|
+
],
|
|
21
|
+
"main": "./dist/index.js",
|
|
22
|
+
"types": "./dist/index.d.ts",
|
|
23
|
+
"publishConfig": {
|
|
24
|
+
"access": "public"
|
|
25
|
+
},
|
|
26
|
+
"scripts": {
|
|
27
|
+
"dev": "tsc --build --watch tsconfig.build.json",
|
|
28
|
+
"build": "npm-run-all clean compile",
|
|
29
|
+
"clean": "del-cli ./dist/ *.tsbuildinfo",
|
|
30
|
+
"compile": "tsc --build tsconfig.build.json",
|
|
31
|
+
"test": "TZ=\"Europe/Istanbul\" vitest run",
|
|
32
|
+
"test:ui": "TZ=\"Europe/Istanbul\" vitest --ui",
|
|
33
|
+
"test:coverage": "TZ=\"Europe/Istanbul\" vitest run --coverage",
|
|
34
|
+
"lint": "run-p lint:*",
|
|
35
|
+
"lint:eslint": "eslint --cache --cache-location ./node_modules/.cache/eslint . --ext .js,.ts,.jsx,.tsx",
|
|
36
|
+
"lint:types": "tsc"
|
|
37
|
+
}
|
|
10
38
|
}
|
package/README.md
DELETED
|
@@ -1,45 +0,0 @@
|
|
|
1
|
-
# @atomicsmash/smash-config
|
|
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 `@atomicsmash/smash-config`
|
|
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**
|