-
Notifications
You must be signed in to change notification settings - Fork 155
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Move GCP upload script to a separate package #74
Merged
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What is this file?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This file is a changeset that records what this PR changed, what packages are affected, and how those packages' versions should be bumped (major / minor / patch). When we publish, I run
changeset version
, and it automatically updates all the package.json files with the correct version increase. Then, it deletes all these pending changeset files and puts them in the changelog for each package.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nice!!