@seyuna/postcss 0.0.1-dev.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/.github/workflows/release.yml +130 -0
- package/dist/functions/color.d.ts +1 -0
- package/dist/functions/color.js +7 -0
- package/dist/functions/index.d.ts +2 -0
- package/dist/functions/index.js +9 -0
- package/dist/functions/spacing.d.ts +1 -0
- package/dist/functions/spacing.js +8 -0
- package/dist/index.d.ts +2 -0
- package/dist/index.js +7 -0
- package/dist/plugin.d.ts +6 -0
- package/dist/plugin.js +25 -0
- package/package.json +25 -0
- package/src/functions/color.js +7 -0
- package/src/functions/color.ts +3 -0
- package/src/functions/index.js +9 -0
- package/src/functions/index.ts +9 -0
- package/src/functions/spacing.js +8 -0
- package/src/functions/spacing.ts +4 -0
- package/src/index.js +7 -0
- package/src/index.ts +2 -0
- package/src/plugin.js +25 -0
- package/src/plugin.ts +32 -0
- package/tsconfig.json +14 -0
|
@@ -0,0 +1,130 @@
|
|
|
1
|
+
name: Build, Release, and Publish
|
|
2
|
+
|
|
3
|
+
on:
|
|
4
|
+
push:
|
|
5
|
+
branches:
|
|
6
|
+
- stable
|
|
7
|
+
- next
|
|
8
|
+
- dev
|
|
9
|
+
workflow_dispatch:
|
|
10
|
+
|
|
11
|
+
permissions:
|
|
12
|
+
contents: write
|
|
13
|
+
id-token: write
|
|
14
|
+
|
|
15
|
+
jobs:
|
|
16
|
+
build:
|
|
17
|
+
name: Build Plugin
|
|
18
|
+
runs-on: ubuntu-latest
|
|
19
|
+
outputs:
|
|
20
|
+
version: ${{ steps.version.outputs.version }}
|
|
21
|
+
|
|
22
|
+
steps:
|
|
23
|
+
- name: Checkout repository
|
|
24
|
+
uses: actions/checkout@v4
|
|
25
|
+
|
|
26
|
+
- name: Read version from package.json
|
|
27
|
+
id: version
|
|
28
|
+
run: |
|
|
29
|
+
VERSION=$(node -p "require('./package.json').version")
|
|
30
|
+
echo "version=$VERSION" >> $GITHUB_OUTPUT
|
|
31
|
+
|
|
32
|
+
- name: Set up Node.js
|
|
33
|
+
uses: actions/setup-node@v4
|
|
34
|
+
with:
|
|
35
|
+
node-version: 20
|
|
36
|
+
registry-url: https://registry.npmjs.org
|
|
37
|
+
|
|
38
|
+
- name: Install dependencies
|
|
39
|
+
run: npm ci
|
|
40
|
+
|
|
41
|
+
- name: Build TypeScript
|
|
42
|
+
run: npm run build
|
|
43
|
+
|
|
44
|
+
- name: List dist contents before upload
|
|
45
|
+
run: ls -l dist
|
|
46
|
+
|
|
47
|
+
- name: Upload build artifact
|
|
48
|
+
uses: actions/upload-artifact@v4
|
|
49
|
+
with:
|
|
50
|
+
name: plugin-dist
|
|
51
|
+
path: dist
|
|
52
|
+
|
|
53
|
+
publish:
|
|
54
|
+
name: Publish to npm
|
|
55
|
+
runs-on: ubuntu-latest
|
|
56
|
+
needs: build
|
|
57
|
+
|
|
58
|
+
steps:
|
|
59
|
+
- name: Checkout repository
|
|
60
|
+
uses: actions/checkout@v4
|
|
61
|
+
|
|
62
|
+
- name: Set up Node.js
|
|
63
|
+
uses: actions/setup-node@v4
|
|
64
|
+
with:
|
|
65
|
+
node-version: 20
|
|
66
|
+
registry-url: https://registry.npmjs.org
|
|
67
|
+
|
|
68
|
+
- name: Download build artifact
|
|
69
|
+
uses: actions/download-artifact@v4
|
|
70
|
+
with:
|
|
71
|
+
name: plugin-dist
|
|
72
|
+
path: dist
|
|
73
|
+
|
|
74
|
+
- name: Authenticate with npm
|
|
75
|
+
run: npm config set //registry.npmjs.org/:_authToken=${{ secrets.NPM_TOKEN }}
|
|
76
|
+
|
|
77
|
+
- name: Determine npm tag
|
|
78
|
+
id: tag
|
|
79
|
+
run: |
|
|
80
|
+
BRANCH="${GITHUB_REF##*/}"
|
|
81
|
+
if [ "$BRANCH" = "main" ]; then
|
|
82
|
+
echo "tag=latest" >> $GITHUB_OUTPUT
|
|
83
|
+
else
|
|
84
|
+
echo "tag=$BRANCH" >> $GITHUB_OUTPUT
|
|
85
|
+
fi
|
|
86
|
+
|
|
87
|
+
- name: Publish package
|
|
88
|
+
run: npm publish --access public --tag ${{ steps.tag.outputs.tag }}
|
|
89
|
+
|
|
90
|
+
release:
|
|
91
|
+
name: Create GitHub Release
|
|
92
|
+
runs-on: ubuntu-latest
|
|
93
|
+
needs: [build, publish]
|
|
94
|
+
|
|
95
|
+
steps:
|
|
96
|
+
- name: Checkout repository
|
|
97
|
+
uses: actions/checkout@v4
|
|
98
|
+
|
|
99
|
+
- name: Download build artifact
|
|
100
|
+
uses: actions/download-artifact@v4
|
|
101
|
+
with:
|
|
102
|
+
name: plugin-dist
|
|
103
|
+
path: dist
|
|
104
|
+
|
|
105
|
+
- name: Generate changelog
|
|
106
|
+
run: |
|
|
107
|
+
last_tag=$(git tag --sort=-creatordate | grep '^v' | grep -v "v${{ needs.build.outputs.version }}" | head -n 1)
|
|
108
|
+
|
|
109
|
+
if [ -z "$last_tag" ]; then
|
|
110
|
+
changelog=$(git log --merges --pretty=format:"* %s (%h)")
|
|
111
|
+
else
|
|
112
|
+
changelog=$(git log "$last_tag"..HEAD --merges --pretty=format:"* %s (%h)")
|
|
113
|
+
fi
|
|
114
|
+
|
|
115
|
+
{
|
|
116
|
+
echo "Automated release for version v${{ needs.build.outputs.version }}"
|
|
117
|
+
echo ""
|
|
118
|
+
echo "## Changes"
|
|
119
|
+
echo ""
|
|
120
|
+
echo "$changelog"
|
|
121
|
+
} > RELEASE_NOTES.md
|
|
122
|
+
|
|
123
|
+
- name: Create GitHub Release
|
|
124
|
+
run: |
|
|
125
|
+
gh release create "v${{ needs.build.outputs.version }}" \
|
|
126
|
+
dist/* \
|
|
127
|
+
--title "v${{ needs.build.outputs.version }}" \
|
|
128
|
+
--notes-file RELEASE_NOTES.md
|
|
129
|
+
env:
|
|
130
|
+
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const cssVar: (name: string, fallback?: string) => string;
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.functions = void 0;
|
|
4
|
+
const color_1 = require("./color");
|
|
5
|
+
const spacing_1 = require("./spacing");
|
|
6
|
+
exports.functions = {
|
|
7
|
+
cssVar: color_1.cssVar,
|
|
8
|
+
spacing: spacing_1.spacing,
|
|
9
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const spacing: (multiplier: string) => string;
|
package/dist/index.d.ts
ADDED
package/dist/index.js
ADDED
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.functions = exports.default = void 0;
|
|
4
|
+
var plugin_1 = require("./plugin");
|
|
5
|
+
Object.defineProperty(exports, "default", { enumerable: true, get: function () { return plugin_1.dynamicFunctionsPlugin; } });
|
|
6
|
+
var functions_1 = require("./functions");
|
|
7
|
+
Object.defineProperty(exports, "functions", { enumerable: true, get: function () { return functions_1.functions; } });
|
package/dist/plugin.d.ts
ADDED
package/dist/plugin.js
ADDED
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.dynamicFunctionsPlugin = void 0;
|
|
4
|
+
const functions_1 = require("./functions");
|
|
5
|
+
const dynamicFunctionsPlugin = (opts = {}) => {
|
|
6
|
+
const fnMap = { ...functions_1.functions, ...opts.functions };
|
|
7
|
+
return {
|
|
8
|
+
postcssPlugin: "postcss-dynamic-functions",
|
|
9
|
+
Declaration(decl) {
|
|
10
|
+
let value = decl.value;
|
|
11
|
+
for (const fnName in fnMap) {
|
|
12
|
+
const regex = new RegExp(`${fnName}\\(([^)]*)\\)`, "g");
|
|
13
|
+
value = value.replace(regex, (_match, argsStr) => {
|
|
14
|
+
const args = argsStr
|
|
15
|
+
.split(",")
|
|
16
|
+
.map((a) => a.trim().replace(/^['"]|['"]$/g, ""));
|
|
17
|
+
return fnMap[fnName](...args);
|
|
18
|
+
});
|
|
19
|
+
}
|
|
20
|
+
decl.value = value;
|
|
21
|
+
},
|
|
22
|
+
};
|
|
23
|
+
};
|
|
24
|
+
exports.dynamicFunctionsPlugin = dynamicFunctionsPlugin;
|
|
25
|
+
exports.dynamicFunctionsPlugin.postcss = true;
|
package/package.json
ADDED
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@seyuna/postcss",
|
|
3
|
+
"version": "0.0.1-dev.0",
|
|
4
|
+
"description": "Seyuna UI's postcss plugin",
|
|
5
|
+
"main": "dist/index.js",
|
|
6
|
+
"types": "dist/index.d.ts",
|
|
7
|
+
"scripts": {
|
|
8
|
+
"build": "tsc",
|
|
9
|
+
"prepare": "npm run build"
|
|
10
|
+
},
|
|
11
|
+
"keywords": [
|
|
12
|
+
"postcss",
|
|
13
|
+
"plugin",
|
|
14
|
+
"seyuna"
|
|
15
|
+
],
|
|
16
|
+
"license": "MIT",
|
|
17
|
+
"peerDependencies": {
|
|
18
|
+
"postcss": "^8.5.6"
|
|
19
|
+
},
|
|
20
|
+
"devDependencies": {
|
|
21
|
+
"@types/node": "^20.0.0",
|
|
22
|
+
"typescript": "^5.0.0",
|
|
23
|
+
"postcss": "^8.5.6"
|
|
24
|
+
}
|
|
25
|
+
}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.functions = void 0;
|
|
4
|
+
const color_1 = require("./color");
|
|
5
|
+
const spacing_1 = require("./spacing");
|
|
6
|
+
exports.functions = {
|
|
7
|
+
cssVar: color_1.cssVar,
|
|
8
|
+
spacing: spacing_1.spacing,
|
|
9
|
+
};
|
package/src/index.js
ADDED
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.functions = exports.default = void 0;
|
|
4
|
+
var plugin_1 = require("./plugin");
|
|
5
|
+
Object.defineProperty(exports, "default", { enumerable: true, get: function () { return plugin_1.dynamicFunctionsPlugin; } });
|
|
6
|
+
var functions_1 = require("./functions");
|
|
7
|
+
Object.defineProperty(exports, "functions", { enumerable: true, get: function () { return functions_1.functions; } });
|
package/src/index.ts
ADDED
package/src/plugin.js
ADDED
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.dynamicFunctionsPlugin = void 0;
|
|
4
|
+
const functions_1 = require("./functions");
|
|
5
|
+
const dynamicFunctionsPlugin = (opts = {}) => {
|
|
6
|
+
const fnMap = { ...functions_1.functions, ...opts.functions };
|
|
7
|
+
return {
|
|
8
|
+
postcssPlugin: "postcss-dynamic-functions",
|
|
9
|
+
Declaration(decl) {
|
|
10
|
+
let value = decl.value;
|
|
11
|
+
for (const fnName in fnMap) {
|
|
12
|
+
const regex = new RegExp(`${fnName}\\(([^)]*)\\)`, "g");
|
|
13
|
+
value = value.replace(regex, (_match, argsStr) => {
|
|
14
|
+
const args = argsStr
|
|
15
|
+
.split(",")
|
|
16
|
+
.map((a) => a.trim().replace(/^['"]|['"]$/g, ""));
|
|
17
|
+
return fnMap[fnName](...args);
|
|
18
|
+
});
|
|
19
|
+
}
|
|
20
|
+
decl.value = value;
|
|
21
|
+
},
|
|
22
|
+
};
|
|
23
|
+
};
|
|
24
|
+
exports.dynamicFunctionsPlugin = dynamicFunctionsPlugin;
|
|
25
|
+
exports.dynamicFunctionsPlugin.postcss = true;
|
package/src/plugin.ts
ADDED
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import { PluginCreator } from "postcss";
|
|
2
|
+
import { functions } from "./functions";
|
|
3
|
+
|
|
4
|
+
interface PluginOptions {
|
|
5
|
+
functions?: Record<string, (...args: string[]) => string>;
|
|
6
|
+
}
|
|
7
|
+
|
|
8
|
+
export const dynamicFunctionsPlugin: PluginCreator<PluginOptions> = (opts = {}) => {
|
|
9
|
+
const fnMap = { ...functions, ...opts.functions };
|
|
10
|
+
|
|
11
|
+
return {
|
|
12
|
+
postcssPlugin: "postcss-dynamic-functions",
|
|
13
|
+
Declaration(decl) {
|
|
14
|
+
let value = decl.value;
|
|
15
|
+
|
|
16
|
+
for (const fnName in fnMap) {
|
|
17
|
+
const regex = new RegExp(`${fnName}\\(([^)]*)\\)`, "g");
|
|
18
|
+
|
|
19
|
+
value = value.replace(regex, (_match, argsStr) => {
|
|
20
|
+
const args = argsStr
|
|
21
|
+
.split(",")
|
|
22
|
+
.map((a: string) => a.trim().replace(/^['"]|['"]$/g, ""));
|
|
23
|
+
return fnMap[fnName](...args);
|
|
24
|
+
});
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
decl.value = value;
|
|
28
|
+
},
|
|
29
|
+
};
|
|
30
|
+
};
|
|
31
|
+
|
|
32
|
+
dynamicFunctionsPlugin.postcss = true;
|
package/tsconfig.json
ADDED
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
{
|
|
2
|
+
"compilerOptions": {
|
|
3
|
+
"target": "ES2020",
|
|
4
|
+
"module": "CommonJS",
|
|
5
|
+
"lib": ["ES2020"],
|
|
6
|
+
"declaration": true,
|
|
7
|
+
"outDir": "dist",
|
|
8
|
+
"strict": true,
|
|
9
|
+
"moduleResolution": "node",
|
|
10
|
+
"esModuleInterop": true,
|
|
11
|
+
"skipLibCheck": true
|
|
12
|
+
},
|
|
13
|
+
"include": ["src/**/*.ts"]
|
|
14
|
+
}
|