Adding the skills
This commit is contained in:
@@ -27,14 +27,14 @@ function parseArgs(argv) {
|
||||
const options = {
|
||||
command,
|
||||
components: [],
|
||||
hostDir: '',
|
||||
hostDirs: [],
|
||||
stagingDir: path.join(cwd, '.glitch-release')
|
||||
}
|
||||
|
||||
for (let index = 0; index < rest.length; index += 1) {
|
||||
const arg = rest[index]
|
||||
if (arg === '--host') {
|
||||
options.hostDir = path.resolve(cwd, rest[index + 1] ?? '')
|
||||
options.hostDirs.push(path.resolve(cwd, rest[index + 1] ?? ''))
|
||||
index += 1
|
||||
continue
|
||||
}
|
||||
@@ -176,6 +176,14 @@ function ensureDirectory(directory) {
|
||||
fs.mkdirSync(directory, { recursive: true })
|
||||
}
|
||||
|
||||
function getDefaultHostDirs() {
|
||||
return [
|
||||
path.resolve(cwd, '..', 'gnommoweb', 'public', 'glitch'),
|
||||
path.resolve(cwd, '..', 'gnommoplayer', 'public', 'glitch'),
|
||||
path.resolve(cwd, '..', 'gnommoeditor', 'public', 'glitch')
|
||||
]
|
||||
}
|
||||
|
||||
function copyDirectoryContents(sourceDir, destinationDir) {
|
||||
ensureDirectory(destinationDir)
|
||||
for (const entry of fs.readdirSync(sourceDir)) {
|
||||
@@ -186,7 +194,7 @@ function copyDirectoryContents(sourceDir, destinationDir) {
|
||||
}
|
||||
}
|
||||
|
||||
function releaseComponent(component, hostDir, stagingDir) {
|
||||
function releaseComponent(component, hostDirs, stagingDir) {
|
||||
const distDir = path.join(component.componentDir, 'dist')
|
||||
if (!fs.existsSync(distDir)) {
|
||||
fail(`Missing dist directory for ${component.componentDirName}. Run build first.`)
|
||||
@@ -205,9 +213,11 @@ function releaseComponent(component, hostDir, stagingDir) {
|
||||
tags: ['legacy']
|
||||
}
|
||||
|
||||
const releaseDir = path.join(hostDir, manifest.folderName)
|
||||
copyDirectoryContents(distDir, releaseDir)
|
||||
fs.writeFileSync(path.join(releaseDir, 'glitch.manifest.json'), `${JSON.stringify(manifest, null, 2)}\n`)
|
||||
for (const hostDir of hostDirs) {
|
||||
const releaseDir = path.join(hostDir, manifest.folderName)
|
||||
copyDirectoryContents(distDir, releaseDir)
|
||||
fs.writeFileSync(path.join(releaseDir, 'glitch.manifest.json'), `${JSON.stringify(manifest, null, 2)}\n`)
|
||||
}
|
||||
|
||||
const stagingComponentDir = path.join(stagingDir, manifest.folderName)
|
||||
copyDirectoryContents(distDir, stagingComponentDir)
|
||||
@@ -268,17 +278,17 @@ switch (options.command) {
|
||||
}
|
||||
|
||||
case 'release': {
|
||||
const hostDir =
|
||||
options.hostDir ||
|
||||
path.resolve(cwd, '..', 'gnommoweb', 'src', 'components', 'glitch')
|
||||
const hostDirs = options.hostDirs.length > 0 ? options.hostDirs : getDefaultHostDirs()
|
||||
|
||||
ensureDirectory(hostDir)
|
||||
for (const hostDir of hostDirs) {
|
||||
ensureDirectory(hostDir)
|
||||
}
|
||||
ensureDirectory(options.stagingDir)
|
||||
|
||||
for (const component of components) {
|
||||
console.log(`=== Releasing ${component.componentDirName} ===`)
|
||||
runBuild(component)
|
||||
releaseComponent(component, hostDir, options.stagingDir)
|
||||
releaseComponent(component, hostDirs, options.stagingDir)
|
||||
}
|
||||
break
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user