- commit
- a84cf61
- parent
- 78d8534
- author
- Eric Bower
- date
- 2023-11-19 17:24:11 +0000 UTC
refactor(npm): use deno arg instead of env var
3 files changed,
+103,
-104
+3,
-0
1@@ -29,3 +29,6 @@ jobs:
2
3 - name: test
4 run: deno task test
5+
6+ - name: npm
7+ run: deno task npm 0.0.0
+1,
-1
1@@ -1,7 +1,7 @@
2 {
3 "tasks": {
4 "types": "deno run --allow-write ./api-type-template.ts",
5- "npm": "deno run --allow-write --allow-read --allow-env --allow-run --allow-net --no-check ./npm.ts",
6+ "npm": "deno run -A ./npm.ts",
7 "test": "deno test --allow-env --allow-read"
8 },
9 "lint": {
M
npm.ts
+99,
-103
1@@ -1,107 +1,103 @@
2 import { build, emptyDir } from "./test.ts";
3
4-main().then(console.log).catch(console.error);
5+await emptyDir("./npm");
6
7-async function main() {
8- await emptyDir("./npm");
9-
10- const version = Deno.env.get("NPM_VERSION");
11- if (!version) {
12- throw new Error("NPM_VERSION is required to build npm package");
13- }
14-
15- await build({
16- declaration: "inline",
17- scriptModule: "cjs",
18- entryPoints: [
19- {
20- name: ".",
21- path: "mod.ts",
22- },
23- {
24- name: "./react",
25- path: "react.ts",
26- },
27- {
28- name: "./store",
29- path: "./store/mod.ts",
30- },
31- {
32- name: "./redux",
33- path: "./redux/mod.ts",
34- },
35- ],
36- mappings: {
37- "https://deno.land/x/effection@3.0.0-beta.2/mod.ts": {
38- name: "effection",
39- version: "3.0.0-beta.2",
40- },
41- "https://esm.sh/react@18.2.0?pin=v122": {
42- name: "react",
43- version: "^18.2.0",
44- peerDependency: true,
45- },
46- "https://esm.sh/react-redux@8.0.5?pin=v122": {
47- name: "react-redux",
48- version: "^8.0.5",
49- },
50- "https://esm.sh/immer@10.0.2?pin=v122": {
51- name: "immer",
52- version: "^10.0.2",
53- },
54- "https://esm.sh/reselect@4.1.8?pin=v122": {
55- name: "reselect",
56- version: "^4.1.8",
57- },
58- "https://esm.sh/robodux@15.0.2?pin=v122": {
59- name: "robodux",
60- version: "^15.0.2",
61- },
62- "https://esm.sh/redux@4.2.1?pin=v122": {
63- name: "redux",
64- version: "^4.2.1",
65- },
66- "https://esm.sh/redux-batched-actions@0.5.0?pin=v122": {
67- name: "redux-batched-actions",
68- version: "^0.5.0",
69- },
70- },
71- outDir: "./npm",
72- shims: {
73- deno: false,
74- },
75- test: false,
76- typeCheck: "both",
77- compilerOptions: {
78- target: "ES2020",
79- sourceMap: true,
80- lib: ["DOM", "DOM.Iterable", "ESNext"],
81- },
82- package: {
83- name: "starfx",
84- version,
85- description:
86- "Async flow control and state management system for deno, node, and browser",
87- license: "MIT",
88- author: {
89- name: "Eric Bower",
90- email: "me@erock.io",
91- },
92- repository: {
93- type: "git",
94- url: "git+https://github.com/neurosnap/starfx.git",
95- },
96- bugs: {
97- url: "https://github.com/neurosnap/starfx/issues",
98- },
99- engines: {
100- node: ">= 18",
101- },
102- sideEffects: false,
103- },
104- postBuild() {
105- Deno.copyFileSync("LICENSE.md", "npm/LICENSE.md");
106- Deno.copyFileSync("README.md", "npm/README.md");
107- },
108- });
109+const [version] = Deno.args;
110+if (!version) {
111+ throw new Error("a version argument is required to build the npm package");
112 }
113+
114+await build({
115+ declaration: "inline",
116+ scriptModule: "cjs",
117+ entryPoints: [
118+ {
119+ name: ".",
120+ path: "mod.ts",
121+ },
122+ {
123+ name: "./react",
124+ path: "react.ts",
125+ },
126+ {
127+ name: "./store",
128+ path: "./store/mod.ts",
129+ },
130+ {
131+ name: "./redux",
132+ path: "./redux/mod.ts",
133+ },
134+ ],
135+ mappings: {
136+ "https://deno.land/x/effection@3.0.0-beta.2/mod.ts": {
137+ name: "effection",
138+ version: "3.0.0-beta.2",
139+ },
140+ "https://esm.sh/react@18.2.0?pin=v122": {
141+ name: "react",
142+ version: "^18.2.0",
143+ peerDependency: true,
144+ },
145+ "https://esm.sh/react-redux@8.0.5?pin=v122": {
146+ name: "react-redux",
147+ version: "^8.0.5",
148+ },
149+ "https://esm.sh/immer@10.0.2?pin=v122": {
150+ name: "immer",
151+ version: "^10.0.2",
152+ },
153+ "https://esm.sh/reselect@4.1.8?pin=v122": {
154+ name: "reselect",
155+ version: "^4.1.8",
156+ },
157+ "https://esm.sh/robodux@15.0.2?pin=v122": {
158+ name: "robodux",
159+ version: "^15.0.2",
160+ },
161+ "https://esm.sh/redux@4.2.1?pin=v122": {
162+ name: "redux",
163+ version: "^4.2.1",
164+ },
165+ "https://esm.sh/redux-batched-actions@0.5.0?pin=v122": {
166+ name: "redux-batched-actions",
167+ version: "^0.5.0",
168+ },
169+ },
170+ outDir: "./npm",
171+ shims: {
172+ deno: false,
173+ },
174+ test: false,
175+ typeCheck: "both",
176+ compilerOptions: {
177+ target: "ES2020",
178+ sourceMap: true,
179+ lib: ["DOM", "DOM.Iterable", "ESNext"],
180+ },
181+ package: {
182+ name: "starfx",
183+ version,
184+ description:
185+ "Async flow control and state management system for deno, node, and browser",
186+ license: "MIT",
187+ author: {
188+ name: "Eric Bower",
189+ email: "me@erock.io",
190+ },
191+ repository: {
192+ type: "git",
193+ url: "git+https://github.com/neurosnap/starfx.git",
194+ },
195+ bugs: {
196+ url: "https://github.com/neurosnap/starfx/issues",
197+ },
198+ engines: {
199+ node: ">= 18",
200+ },
201+ sideEffects: false,
202+ },
203+ postBuild() {
204+ Deno.copyFileSync("LICENSE.md", "npm/LICENSE.md");
205+ Deno.copyFileSync("README.md", "npm/README.md");
206+ },
207+});