-
Notifications
You must be signed in to change notification settings - Fork 154
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Move GCP upload script to a separate package
- Loading branch information
1 parent
f966e57
commit daf19a8
Showing
9 changed files
with
222 additions
and
37 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
--- | ||
'@visualblocks/tsconfig': minor | ||
'@visualblocks/gemini': minor | ||
--- | ||
|
||
Move GCP upload script to a separate scripts package |
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
This file was deleted.
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 |
---|---|---|
@@ -0,0 +1 @@ | ||
export {default} from '@visualblocks/eslint-config'; |
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,28 @@ | ||
{ | ||
"name": "@visualblocks/scripts", | ||
"private": "true", | ||
"description": "Script for uploading a package to gcp", | ||
"type": "module", | ||
"files": [ | ||
"dist/**" | ||
], | ||
"license": "Apache-2.0", | ||
"bin": { | ||
"upload-to-gcp": "./dist/upload-to-gcp.js" | ||
}, | ||
"scripts": { | ||
"build": "tsc", | ||
"clean": "rm -rf .turbo && rm -rf node_modules && rm -rf dist", | ||
"lint": "eslint .", | ||
"upload-to-gcp": "upload-to-gcp" | ||
}, | ||
"devDependencies": { | ||
"@types/argparse": "^2.0.16", | ||
"@types/node": "^22.5.4", | ||
"@visualblocks/tsconfig": "*" | ||
}, | ||
"dependencies": { | ||
"argparse": "^2.0.1", | ||
"chalk": "^5.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,55 @@ | ||
#!/usr/bin/env node | ||
|
||
import {ArgumentParser} from 'argparse'; | ||
import {exec} from 'child_process'; | ||
import * as fs from 'node:fs/promises'; | ||
import * as path from 'path'; | ||
import chalk from 'chalk'; | ||
|
||
function $(command: string) { | ||
console.log(chalk.gray(command)); | ||
return exec(command); | ||
} | ||
|
||
export async function uploadPackageToGcp(packagePath = '.') { | ||
packagePath = await fs.realpath(packagePath); | ||
|
||
const packageJsonData = await fs.readFile( | ||
path.join(packagePath, 'package.json') | ||
); | ||
|
||
const packageJson = JSON.parse(packageJsonData.toString('utf8')); | ||
const {name, version} = packageJson; | ||
|
||
console.log(`Uploading ${chalk.bold(name)} to GCP`); | ||
|
||
const versionedGcpPackagePath = `gs://tfweb/visualblocks-github-bundles/${name}@${version}/`; | ||
const latestGcpPackagePath = `gs://tfweb/visualblocks-github-bundles/${name}@latest/`; | ||
|
||
for (const gcpPath of [versionedGcpPackagePath, latestGcpPackagePath]) { | ||
$(`cd ${packagePath} && gcloud storage cp -r package.json ${gcpPath}`); | ||
|
||
// Copy the dist/ bundles and sourcemaps. | ||
// The src/ directory is not required for sourcemaps to work since they bundle | ||
// the source code themselves. | ||
$(`cd ${packagePath} && gcloud storage cp -r dist ${gcpPath}`); | ||
} | ||
} | ||
|
||
async function main() { | ||
const parser = new ArgumentParser({ | ||
description: | ||
'Upload a package to the VisualBlocks GitHub GCP bucket. Run in the root directory of the package to upload.', | ||
}); | ||
|
||
parser.add_argument('-p', '--package', { | ||
help: 'The path to the root directory of the package to upload', | ||
type: String, | ||
default: '.', | ||
}); | ||
const args = parser.parse_args(); | ||
|
||
uploadPackageToGcp(args['packagePath'] as string); | ||
} | ||
|
||
main().catch((e: Error) => console.error(e)); |
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,8 @@ | ||
{ | ||
"extends": "@visualblocks/tsconfig/tsconfig.json", | ||
"compilerOptions": { | ||
"noEmit": false, | ||
"outDir": "dist" | ||
}, | ||
"include": ["*.ts", "src/**/*.ts", "src/upload-to-gcp.ts~"] | ||
} |
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