Skip to content

Commit 08e5e10

Browse files
committed
Add CI/CD Pipelines
1 parent b30cb00 commit 08e5e10

File tree

6 files changed

+107
-1307
lines changed

6 files changed

+107
-1307
lines changed

builder.js

Lines changed: 41 additions & 47 deletions
Original file line numberDiff line numberDiff line change
@@ -1,30 +1,37 @@
11
/**
22
* Written by Denis Power.
33
*
4-
* globalconfig.json options.
4+
* builderconfig options.
55
*
66
* {
7-
* files: [],
7+
* files: string[],
88
* dir: "./core",
9-
* types: "./types"
9+
* types: {
10+
* dir: "./types",
11+
* files: string[]
12+
* }
1013
* }
1114
*
1215
*
1316
*
1417
*/
1518

16-
const { writeFileSync, readFileSync, readdirSync } = require("fs");
17-
const { format } = require("prettier");
18-
const config = getConfig();
19+
console.log("Building...")
20+
21+
import builderconfig from "./builderconfig.js";
22+
import { writeFileSync, readFileSync, readdirSync } from "node:fs";
23+
import { format } from "prettier";
24+
25+
const {
26+
version,
27+
year,
28+
files,
29+
dir,
30+
types: { dir: typeDir, version: typeVersion },
31+
} = builderconfig;
32+
1933
const Package = JSON.parse(readFileSync("./package.json"));
2034
const packageLock = JSON.parse(readFileSync("./package-lock.json"));
21-
const buildVersion = process.argv[2];
22-
const buildYear = process.argv[3];
23-
const buildType = process.argv[4];
24-
const typeVersion = process.argv[5];
25-
const isGlobalBuild = buildType.toUpperCase() == "GLOBAL";
26-
const isModuleBuild = buildType.toUpperCase() == "MODULE";
27-
const isTsDeclaration = buildType.toUpperCase() == "TYPES";
2835

2936
class Inter {
3037
#source;
@@ -120,38 +127,21 @@ function isBlankSpace(code) {
120127
return /\s/.test(code);
121128
}
122129

123-
function getConfig() {
124-
const resultObject = {
125-
hasFile: false,
126-
file: void 0,
127-
};
128-
129-
try {
130-
resultObject.file = JSON.parse(readFileSync("./builderconfig.json"));
131-
resultObject.hasFile = true;
132-
} catch (e) {
133-
/*No globalconfig.json*/
134-
}
135-
136-
return resultObject;
137-
}
138-
139-
if (!config.hasFile) throw new Error("No `globalconfig.json` file found");
130+
if (!files) throw new Error("No `builderconfing.js` file found");
140131

141132
function buildTsDeclaration() {
142-
const { types } = config.file;
143-
const files = readdirSync(types);
144133
let body = "";
134+
const typeFiles = readdirSync(typeDir);
145135

146-
for (const file of files) {
147-
const fileString = readFileSync(`${types}/${file}`);
136+
for (const file of typeFiles) {
137+
const fileString = readFileSync(`${typeDir}/${file}`);
148138
body += fileString;
149139
}
150140

151141
body = `
152142
/***
153143
* MIT LICENSED BY - Denis Power(Inter creator)
154-
* Typescript declaration file for Inter version ${buildVersion}
144+
* Typescript declaration file for Inter version ${version}
155145
* Version - ${typeVersion}
156146
* Repo - https://github.com/interjs/inter/types
157147
* GENERATED BY INTER BUILDER
@@ -164,8 +154,9 @@ function buildTsDeclaration() {
164154
writeFileSync("inter.m.d.ts", body);
165155
}
166156

167-
function build() {
168-
const { files, dir } = config.file;
157+
function build(buildType) {
158+
const isModuleBuild = buildType == "module";
159+
const isGlobalBuild = buildType == "global";
169160

170161
let body = "";
171162

@@ -208,10 +199,10 @@ function build() {
208199
209200
/**
210201
* Interjs
211-
* Version - ${buildVersion}
202+
* Version - ${version}
212203
* MIT LICENSED BY - Denis Power
213204
* Repo - https://github.com/interjs/inter
214-
* 2021 - ${buildYear}
205+
* 2021 - ${year}
215206
* GENERATED BY INTER BUILDER
216207
*
217208
*/
@@ -226,7 +217,7 @@ function build() {
226217
window.template = template;
227218
window.toAttrs = toAttrs;
228219
window.Backend = Backend;
229-
console.log("The global version ${buildVersion} of Inter was loaded successfully.")
220+
console.log("The global version ${version} of Inter was loaded successfully.")
230221
231222
})();
232223
@@ -236,28 +227,31 @@ function build() {
236227
237228
/**
238229
* Interjs
239-
* Version - ${buildVersion}
230+
* Version - ${version}
240231
* MIT LICENSED BY - Denis Power
241232
* Repo - https://github.com/interjs/inter
242-
* 2021 - ${buildYear}
233+
* 2021 - ${year}
243234
* GENERATED BY INTER BUILDER
244235
* Module version
245236
*/
246237
247-
export const interVersion = "${buildVersion}";
238+
export const interVersion = "${version}";
248239
${builtCode}
249240
`;
250241
}
251242

252243
if (isGlobalBuild) writeFileSync("inter.js", format(body));
253244
else if (isModuleBuild) writeFileSync("inter.m.js", format(body));
254245

255-
Package.version = buildVersion;
256-
packageLock.version = buildVersion;
246+
Package.version = version;
247+
packageLock.version = version;
257248

258249
writeFileSync("package.json", JSON.stringify(Package));
259250
writeFileSync("package-lock.json", JSON.stringify(packageLock));
260251
}
261252

262-
if (isTsDeclaration) buildTsDeclaration();
263-
else build();
253+
buildTsDeclaration();
254+
build("global");
255+
build("module");
256+
257+
console.log("Inter Built Successfully")

builderconfig.js

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
export default {
2+
version: "2.2.4",
3+
year: "2025",
4+
files: [
5+
"template/errors.js",
6+
"renderList/errors.js",
7+
"ajax/errors.js",
8+
"ref/errors.js",
9+
"renderif/errors.js",
10+
"toattrs/errors.js",
11+
"helpers.js",
12+
"ref/index.js",
13+
"toattrs/index.js",
14+
"renderif/index.js",
15+
"template/index.js",
16+
"renderList/index.js",
17+
"ajax/index.js",
18+
],
19+
dir: "./core",
20+
types: {
21+
dir: "./types",
22+
version: "1.0.0",
23+
},
24+
};

builderconfig.json

Lines changed: 0 additions & 19 deletions
This file was deleted.

inter.m.d.ts

Lines changed: 40 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,13 @@
1-
/***
2-
* MIT LICENSED BY - Denis Power(Inter creator)
3-
* Typescript declaration file for Inter version 2.2.3
4-
* Version - 1.0.0
5-
* Repo - https://github.com/interjs/inter/types
6-
* GENERATED BY INTER BUILDER
7-
*/
81

9-
interface backendInterface {
2+
/***
3+
* MIT LICENSED BY - Denis Power(Inter creator)
4+
* Typescript declaration file for Inter version 2.2.4
5+
* Version - 1.0.0
6+
* Repo - https://github.com/interjs/inter/types
7+
* GENERATED BY INTER BUILDER
8+
*/
9+
10+
interface backendInterface {
1011
new (): backendInstance;
1112
}
1213

@@ -41,8 +42,8 @@ interface ajaxOptions {
4142
};
4243
security?: {
4344
username: string;
44-
password: string;
45-
};
45+
password: string
46+
}
4647
body?: any;
4748
}
4849

@@ -67,9 +68,9 @@ interface ajaxResponse {
6768
export declare var Backend: backendInterface;
6869
type refValueType = string | number | null | void;
6970
type refMethods<T> = {
70-
setRefs?: {
71-
[ref in keyof T]?: refValueType;
72-
};
71+
setRefs?: {
72+
[ref in keyof T]?: refValueType
73+
}
7374
observe(
7475
ref: string,
7576
value: refValueType,
@@ -85,9 +86,10 @@ interface refOptionsInterface<T> {
8586
export declare function Ref<T extends object>(
8687
options: refOptionsInterface<T>
8788
): refMethods<T> & T;
89+
type refValueType = boolean;
8890
type renderIfMethods<T> = {
8991
setConds: {
90-
[prop in keyof T]?: refValueType;
92+
[prop in keyof T]?: refValueType
9193
};
9294
observe(ref: keyof T, value: refValueType): boolean;
9395
};
@@ -102,6 +104,7 @@ interface renderIfOptionsInterface<T> {
102104
export declare function renderIf<T extends object>(
103105
options: renderIfOptionsInterface<T>
104106
): renderIfMethods<T> & T;
107+
import { templateReturn } from "./template";
105108

106109
interface renderListOptionsInterface<T> {
107110
in: string;
@@ -157,36 +160,31 @@ export declare function renderList<T extends eachTypes>(
157160
renderListOption: renderListOptionsInterface<T>
158161
): returnReactorType<T>;
159162

160-
type HTMLTags = keyof HTMLElementTagNameMap;
161-
type textTypes = string | number | null | void;
163+
type HTMLTags = keyof HTMLElementTagNameMap;
164+
type textTypes = string | number | null | void
162165
interface templateOptionsInterface {
163-
tag: HTMLTags | ((this: void) => HTMLTags);
164-
text?: textTypes | ((this: void) => textTypes);
165-
renderIf?: boolean;
166-
events?: {
167-
[event in keyof GlobalEventHandlers]?: (
168-
this: Document,
169-
event: Event
170-
) => void;
171-
};
172-
attrs?: object;
173-
styles?: {
174-
[style in keyof CSSStyleDeclaration]?: CSSStyleDeclaration[style];
175-
};
176-
children?: templateOptionsInterface[];
166+
tag: HTMLTags| ((this: void) => HTMLTags),
167+
text?: textTypes | ((this: void) => textTypes),
168+
renderIf?: boolean,
169+
events?: {
170+
[event in keyof GlobalEventHandlers]?: (this: Document, event: Event) => void;
171+
}
172+
attrs?: object,
173+
styles?: {
174+
[style in keyof CSSStyleDeclaration]?: CSSStyleDeclaration[style]
175+
}
176+
children?: templateOptionsInterface[]
177177
}
178178

179-
interface templateReturn {
180-
element: templateOptionsInterface;
179+
export interface templateReturn {
180+
element: templateOptionsInterface
181181
}
182182

183-
export declare function template(
184-
options: templateOptionsInterface
185-
): templateReturn;
186-
type attrType = string | number | null;
187-
type attrs<T> = T[keyof T];
188-
interface toAttrsMethods<T> {
189-
setAttrs?: T[keyof T];
183+
184+
export declare function template(options: templateOptionsInterface): templateReturn;type attrType = string | number | null;
185+
type attrs <T> = T[keyof T];
186+
interface toAttrsMethods<T>{
187+
setAttrs?: T[keyof T]
190188
observe?(attr: string, value: attrType): boolean;
191189
}
192190

@@ -200,3 +198,6 @@ export declare function toAttrs<T extends object>(
200198
): {
201199
[prop in keyof T]: toAttrsMethods<T> & T[prop];
202200
};
201+
202+
203+

0 commit comments

Comments
 (0)