Skip to content

Commit

Permalink
squash!
Browse files Browse the repository at this point in the history
  • Loading branch information
NikolaRHristov committed Feb 12, 2024
1 parent db08281 commit f187108
Show file tree
Hide file tree
Showing 14 changed files with 162 additions and 41 deletions.
49 changes: 36 additions & 13 deletions Source/Command/Cloudflare.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,44 +13,64 @@
export default async () =>
await (async (Files: Files) => {
for (const { Path, Name, File } of Files) {
for (const [directory, packageFiles] of await (
for (const [_Directory, FilesPackage] of await (
await import("../Function/Directory.js")
).default(
await (await import("../Function/Package.js")).default(
"Cloudflare",
),
)) {
const GitHub = `${directory}/.github`;
const GitHub = `${_Directory}/.github`;
const Base = await File();

if (Path === "/workflows/" && Name === "Cloudflare.yml") {
for (const _package of packageFiles) {
const packageDirectory = (await import("path"))
.dirname(_package)
.replace(directory, "");
for (const Package of FilesPackage) {
const Directory = (await import("path"))
.dirname(Package)
.replace(_Directory, "");

const environment = (
const Environment = (
await (
await import("../Function/Type.js")
).default()
).get(_package.split("/").pop());
).get(Package.split("/").pop());

if (
typeof environment !== "undefined" &&
environment === "Cloudflare"
typeof Environment !== "undefined" &&
Environment === "Cloudflare"
) {
Base.add(`
- uses: cloudflare/[email protected]
with:
apiToken: \${{ secrets.CF_API_TOKEN }}
accountId: \${{ secrets.CF_ACCOUNT_ID }}
workingDirectory: .${packageDirectory}
workingDirectory: .${Directory}
`);
}
}
}

console.log(Base);
let Branch = "main";

try {
await (await import("fs/promises")).access(
_Directory,
(await import("fs/promises")).constants.F_OK,
);

const Current = process.cwd();

process.chdir(_Directory);

Branch = (await import("child_process"))
.execSync("git rev-parse --abbrev-ref HEAD")
.toString()
.trim();

process.chdir(Current);
} catch (_Error) {
console.log(`Could not access: ${_Directory}`);
}

if (Base.size > 1) {
try {
Expand All @@ -67,7 +87,10 @@ export default async () =>
try {
await (await import("fs/promises")).writeFile(
`${GitHub}${Path}${Name}`,
`${[...Base].join("")}`,
`${[...Base].join("")}`.replaceAll(
"$Branch$",
Branch,
),
);
} catch {
console.log(
Expand Down
27 changes: 26 additions & 1 deletion Source/Command/Node.ts
Original file line number Diff line number Diff line change
Expand Up @@ -136,6 +136,28 @@ export default async () =>
}
}

let Branch = "main";

try {
await (await import("fs/promises")).access(
_Directory,
(await import("fs/promises")).constants.F_OK,
);

const Current = process.cwd();

process.chdir(_Directory);

Branch = (await import("child_process"))
.execSync("git rev-parse --abbrev-ref HEAD")
.toString()
.trim();

process.chdir(Current);
} catch (_Error) {
console.log(`Could not access: ${_Directory}`);
}

if (Base.size > 1) {
try {
await (await import("fs/promises")).mkdir(
Expand All @@ -151,7 +173,10 @@ export default async () =>
try {
await (await import("fs/promises")).writeFile(
`${GitHub}${Path}${Name}`,
`${[...Base].join("")}`,
`${[...Base].join("")}`.replaceAll(
"$Branch$",
Branch,
),
);
} catch {
console.log(
Expand Down
27 changes: 26 additions & 1 deletion Source/Command/Rust.ts
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,28 @@ export default async () =>
}
}

let Branch = "main";

try {
await (await import("fs/promises")).access(
_Directory,
(await import("fs/promises")).constants.F_OK,
);

const Current = process.cwd();

process.chdir(_Directory);

Branch = (await import("child_process"))
.execSync("git rev-parse --abbrev-ref HEAD")
.toString()
.trim();

process.chdir(Current);
} catch (_Error) {
console.log(`Could not access: ${_Directory}`);
}

if (Base.size > 1) {
try {
await (await import("fs/promises")).mkdir(
Expand All @@ -75,7 +97,10 @@ export default async () =>
try {
await (await import("fs/promises")).writeFile(
`${GitHub}${Path}${Name}`,
`${[...Base].join("")}`,
`${[...Base].join("")}`.replaceAll(
"$Branch$",
Branch,
),
);
} catch {
console.log(
Expand Down
4 changes: 2 additions & 2 deletions Source/Workflow/Cloudflare.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,9 @@ permissions:
on:
workflow_dispatch:
push:
branches: [%DEFAULT%]
branches: [$Branch$]
pull_request:
branches: [%DEFAULT%]
branches: [$Branch$]
workflow_call:

jobs:
Expand Down
4 changes: 2 additions & 2 deletions Source/Workflow/Node.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,9 @@ permissions:
on:
workflow_dispatch:
push:
branches: [%DEFAULT%]
branches: [$Branch$]
pull_request:
branches: [%DEFAULT%]
branches: [$Branch$]
workflow_call:

jobs:
Expand Down
4 changes: 2 additions & 2 deletions Source/Workflow/Rust.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,9 @@ permissions:
on:
workflow_dispatch:
push:
branches: [%DEFAULT%]
branches: [$Branch$]
pull_request:
branches: [%DEFAULT%]
branches: [$Branch$]
workflow_call:

jobs:
Expand Down
4 changes: 2 additions & 2 deletions Source/Workflow/codeql.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,9 @@ permissions:
on:
workflow_dispatch:
push:
branches: [%DEFAULT%]
branches: [$Branch$]
pull_request:
branches: [%DEFAULT%]
branches: [$Branch$]
workflow_call:

jobs:
Expand Down
32 changes: 24 additions & 8 deletions Target/Command/Cloudflare.js
Original file line number Diff line number Diff line change
@@ -1,27 +1,40 @@
var Cloudflare_default = async () => await (async (Files) => {
for (const { Path, Name, File } of Files) {
for (const [directory, packageFiles] of await (await import("../Function/Directory.js")).default(
for (const [_Directory, FilesPackage] of await (await import("../Function/Directory.js")).default(
await (await import("../Function/Package.js")).default(
"Cloudflare"
)
)) {
const GitHub = `${directory}/.github`;
const GitHub = `${_Directory}/.github`;
const Base = await File();
if (Path === "/workflows/" && Name === "Cloudflare.yml") {
for (const _package of packageFiles) {
const packageDirectory = (await import("path")).dirname(_package).replace(directory, "");
const environment = (await (await import("../Function/Type.js")).default()).get(_package.split("/").pop());
if (typeof environment !== "undefined" && environment === "Cloudflare") {
for (const Package of FilesPackage) {
const Directory = (await import("path")).dirname(Package).replace(_Directory, "");
const Environment = (await (await import("../Function/Type.js")).default()).get(Package.split("/").pop());
if (typeof Environment !== "undefined" && Environment === "Cloudflare") {
Base.add(`
- uses: cloudflare/[email protected]
with:
apiToken: \${{ secrets.CF_API_TOKEN }}
accountId: \${{ secrets.CF_ACCOUNT_ID }}
workingDirectory: .${packageDirectory}
workingDirectory: .${Directory}
`);
}
}
}
let Branch = "main";
try {
await (await import("fs/promises")).access(
_Directory,
(await import("fs/promises")).constants.F_OK
);
const Current = process.cwd();
process.chdir(_Directory);
Branch = (await import("child_process")).execSync("git rev-parse --abbrev-ref HEAD").toString().trim();
process.chdir(Current);
} catch (_Error) {
console.log(`Could not access: ${_Directory}`);
}
if (Base.size > 1) {
try {
await (await import("fs/promises")).mkdir(
Expand All @@ -36,7 +49,10 @@ var Cloudflare_default = async () => await (async (Files) => {
try {
await (await import("fs/promises")).writeFile(
`${GitHub}${Path}${Name}`,
`${[...Base].join("")}`
`${[...Base].join("")}`.replaceAll(
"$Branch$",
Branch
)
);
} catch {
console.log(
Expand Down
18 changes: 17 additions & 1 deletion Target/Command/Node.js
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,19 @@ var Node_default = async () => await (async (Files) => {
}
}
}
let Branch = "main";
try {
await (await import("fs/promises")).access(
_Directory,
(await import("fs/promises")).constants.F_OK
);
const Current = process.cwd();
process.chdir(_Directory);
Branch = (await import("child_process")).execSync("git rev-parse --abbrev-ref HEAD").toString().trim();
process.chdir(Current);
} catch (_Error) {
console.log(`Could not access: ${_Directory}`);
}
if (Base.size > 1) {
try {
await (await import("fs/promises")).mkdir(
Expand All @@ -102,7 +115,10 @@ var Node_default = async () => await (async (Files) => {
try {
await (await import("fs/promises")).writeFile(
`${GitHub}${Path}${Name}`,
`${[...Base].join("")}`
`${[...Base].join("")}`.replaceAll(
"$Branch$",
Branch
)
);
} catch {
console.log(
Expand Down
18 changes: 17 additions & 1 deletion Target/Command/Rust.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,19 @@ var Rust_default = async () => await (async (Files) => {
}
}
}
let Branch = "main";
try {
await (await import("fs/promises")).access(
_Directory,
(await import("fs/promises")).constants.F_OK
);
const Current = process.cwd();
process.chdir(_Directory);
Branch = (await import("child_process")).execSync("git rev-parse --abbrev-ref HEAD").toString().trim();
process.chdir(Current);
} catch (_Error) {
console.log(`Could not access: ${_Directory}`);
}
if (Base.size > 1) {
try {
await (await import("fs/promises")).mkdir(
Expand All @@ -43,7 +56,10 @@ var Rust_default = async () => await (async (Files) => {
try {
await (await import("fs/promises")).writeFile(
`${GitHub}${Path}${Name}`,
`${[...Base].join("")}`
`${[...Base].join("")}`.replaceAll(
"$Branch$",
Branch
)
);
} catch {
console.log(
Expand Down
4 changes: 2 additions & 2 deletions Target/Workflow/Cloudflare.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,9 @@ permissions:
on:
workflow_dispatch:
push:
branches: [main]
branches: [$Branch$]
pull_request:
branches: [main]
branches: [$Branch$]
workflow_call:

jobs:
Expand Down
4 changes: 2 additions & 2 deletions Target/Workflow/Node.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,9 @@ permissions:
on:
workflow_dispatch:
push:
branches: [main]
branches: [$Branch$]
pull_request:
branches: [main]
branches: [$Branch$]
workflow_call:

jobs:
Expand Down
4 changes: 2 additions & 2 deletions Target/Workflow/Rust.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,9 @@ permissions:
on:
workflow_dispatch:
push:
branches: [main]
branches: [$Branch$]
pull_request:
branches: [main]
branches: [$Branch$]
workflow_call:

jobs:
Expand Down
4 changes: 2 additions & 2 deletions Target/Workflow/codeql.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,9 @@ permissions:
on:
workflow_dispatch:
push:
branches: [main]
branches: [$Branch$]
pull_request:
branches: [main]
branches: [$Branch$]
workflow_call:

jobs:
Expand Down

0 comments on commit f187108

Please sign in to comment.