-
Notifications
You must be signed in to change notification settings - Fork 101
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Working method to add version to Issue Templates
Produces weird artifacts...
- Loading branch information
1 parent
3d643a7
commit f63480e
Showing
7 changed files
with
245 additions
and
26 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -46,6 +46,7 @@ | |
"upath": "^2.0.1" | ||
}, | ||
"dependencies": { | ||
"js-yaml": "^4.1.0", | ||
"md5": "^2.3.0" | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
import gulp from "gulp"; | ||
import rename from "gulp-rename"; | ||
import merge from "merge-stream"; | ||
import upath from "upath"; | ||
import buildConfig from "../../buildConfig"; | ||
import { langDestDirectory, overridesFolder, sharedDestDirectory } from "../../globals"; | ||
import fs from "fs"; | ||
|
||
/** | ||
* Checks and creates all necessary directories so we can build the client safely. | ||
*/ | ||
async function createLangDirs() { | ||
if (!fs.existsSync(langDestDirectory)) { | ||
await fs.promises.mkdir(langDestDirectory, { recursive: true }); | ||
} | ||
} | ||
|
||
async function copyLang() { | ||
const resourcesPath = upath.join(sharedDestDirectory, overridesFolder, "resources"); | ||
|
||
const opts = { nodir: true, base: resourcesPath }; | ||
const streams = [ | ||
gulp.src(upath.join(resourcesPath, "pack.mcmeta"), opts), | ||
gulp.src(upath.join(resourcesPath, "**/*.lang"), opts).pipe( | ||
rename((f) => { | ||
f.dirname = upath.join("assets", f.dirname); | ||
}), | ||
), | ||
]; | ||
|
||
return await new Promise((resolve) => { | ||
merge(...streams) | ||
.pipe(gulp.dest(upath.join(buildConfig.buildDestinationDirectory, langDestDirectory))) | ||
.on("end", resolve); | ||
}); | ||
} | ||
|
||
export default gulp.series(createLangDirs, copyLang); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
import fs from "fs"; | ||
import upath from "upath"; | ||
import gulp from "gulp"; | ||
import yaml from "js-yaml"; | ||
|
||
import { issueTemplatesFolder } from "../../globals"; | ||
import { IssueInput } from "../../types/issueInput"; | ||
|
||
// The name of the 'body' object. | ||
const bodyID: string = 'body'; | ||
|
||
// The id of the version input field, in both Issue Templates. | ||
const versionInputID: string = 'version'; | ||
|
||
// Temp/Debug | ||
const tempVersionField: string = '2.0'; | ||
|
||
async function updateIssueTemplate(filepath : string) { | ||
// Load the yaml file, and get its 'body' | ||
const file: object = yaml.load(await fs.promises.readFile(filepath)); | ||
const fileBody: object[] = file[bodyID]; | ||
|
||
const newFileBody: object[] = []; | ||
fileBody.forEach((input: IssueInput) => { | ||
if (input.id == versionInputID) { | ||
const versions: string[] = input.attributes.options; | ||
|
||
// Add new version to start of list | ||
versions.unshift(tempVersionField); | ||
|
||
// Load new version list | ||
input.attributes.options = versions; // May not be needed, but just incase | ||
} | ||
newFileBody.push(input); | ||
}); | ||
|
||
// Set new file body | ||
file[bodyID] = newFileBody; // May not be needed | ||
|
||
// Write file | ||
fs.promises.writeFile(filepath, yaml.dump(file)); | ||
} | ||
|
||
// This can be added to with new issue templates. | ||
export async function updateIssueTemplates() : Promise<void> { | ||
updateIssueTemplate(upath.join(issueTemplatesFolder, "001-bug-report.yml")); | ||
updateIssueTemplate(upath.join(issueTemplatesFolder, "002-feature-request.yml")); | ||
} |
Oops, something went wrong.