summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBrandon Keiji <[email protected]>2025-04-21 23:11:51 -0700
committerGitHub <[email protected]>2025-04-21 23:11:51 -0700
commit79710375e3477ec821aa889c02eb64f2529440af (patch)
tree51552ebfba9606bf82aad079bc3b9a31452b51d7
parent98fa8d2b5134dd919dffb7cb68a3f97dad0b159f (diff)
fix: point npmrc to dogfood artifact registry (#108)
-rw-r--r--.npmrc4
-rw-r--r--package-lock.json12
-rw-r--r--package.json6
-rw-r--r--packages/cli/package.json4
-rw-r--r--packages/server/package.json4
-rw-r--r--scripts/bind_package_dependencies.js50
-rw-r--r--scripts/bind_package_version.js50
7 files changed, 122 insertions, 8 deletions
diff --git a/.npmrc b/.npmrc
index ea2c1bc9..80827955 100644
--- a/.npmrc
+++ b/.npmrc
@@ -1,3 +1,3 @@
; TODO(b/411429188): re-enable and migrate once our private GCP project is up
-# @gemin-code-dev:registry=https://us-west1-npm.pkg.dev/kkb-dev/gemini-code/
-# //us-west1-npm.pkg.dev/kkb-dev/gemini-code/:always-auth=true \ No newline at end of file
+; @gemini-code:registry=https://us-west1-npm.pkg.dev/gemini-code-dev/gemini-code/
+; //us-west1-npm.pkg.dev/gemini-code-dev/gemini-code/:always-auth=true
diff --git a/package-lock.json b/package-lock.json
index 98e0140b..f19557fc 100644
--- a/package-lock.json
+++ b/package-lock.json
@@ -1,12 +1,12 @@
{
"name": "gemini-code",
- "version": "1.0.0",
+ "version": "0.1.0",
"lockfileVersion": 3,
"requires": true,
"packages": {
"": {
"name": "gemini-code",
- "version": "1.0.0",
+ "version": "0.1.0",
"workspaces": [
"packages/*"
],
@@ -18,6 +18,7 @@
"eslint-plugin-react": "^7.37.5",
"eslint-plugin-react-hooks": "^5.2.0",
"globals": "^16.0.0",
+ "lodash": "^4.17.21",
"prettier": "^3.5.3",
"typescript-eslint": "^8.30.1"
}
@@ -4344,6 +4345,13 @@
"url": "https://github.com/sponsors/sindresorhus"
}
},
+ "node_modules/lodash": {
+ "version": "4.17.21",
+ "resolved": "https://registry.npmjs.org/lodash/-/lodash-4.17.21.tgz",
+ "integrity": "sha512-v2kDEe57lecTulaDIuNTPy3Ry4gLGJ6Z1O3vE1krgXZNrsQ+LFTGHVxVjcXPs17LhbZVGedAJv8XZ1tvj5FvSg==",
+ "dev": true,
+ "license": "MIT"
+ },
"node_modules/lodash.merge": {
"version": "4.6.2",
"resolved": "https://registry.npmjs.org/lodash.merge/-/lodash.merge-4.6.2.tgz",
diff --git a/package.json b/package.json
index dd6a23a1..85d0b6c4 100644
--- a/package.json
+++ b/package.json
@@ -1,6 +1,6 @@
{
"name": "gemini-code",
- "version": "1.0.0",
+ "version": "0.1.0",
"private": true,
"type": "module",
"workspaces": [
@@ -17,7 +17,8 @@
"typecheck": "tsc --noEmit --jsx react",
"format": "prettier --write .",
"preflight": "npm run format --workspaces --if-present && npm run lint --workspaces --if-present && npm run test --workspaces --if-present",
- "artifactregistry-login": "npx google-artifactregistry-auth"
+ "artifactregistry-login": "npx google-artifactregistry-auth",
+ "stage": "npm run stage:version --workspaces && npm run stage:deps --workspaces"
},
"devDependencies": {
"eslint": "^9.24.0",
@@ -27,6 +28,7 @@
"eslint-plugin-react": "^7.37.5",
"eslint-plugin-react-hooks": "^5.2.0",
"globals": "^16.0.0",
+ "lodash": "^4.17.21",
"prettier": "^3.5.3",
"typescript-eslint": "^8.30.1"
}
diff --git a/packages/cli/package.json b/packages/cli/package.json
index 6acb2c62..436a4b77 100644
--- a/packages/cli/package.json
+++ b/packages/cli/package.json
@@ -12,7 +12,9 @@
"debug": "node --inspect-brk dist/gemini.js",
"lint": "eslint . --ext .ts,.tsx",
"format": "prettier --write .",
- "test": "vitest run"
+ "test": "vitest run",
+ "stage:version": "node ../../scripts/bind_package_version.js",
+ "stage:deps": "node ../../scripts/bind_package_dependencies.js"
},
"files": [
"dist"
diff --git a/packages/server/package.json b/packages/server/package.json
index 433bed53..fcab1e7c 100644
--- a/packages/server/package.json
+++ b/packages/server/package.json
@@ -10,7 +10,9 @@
"clean": "rm -rf dist",
"lint": "eslint . --ext .ts,.tsx",
"format": "prettier --write .",
- "test": "vitest run"
+ "test": "vitest run",
+ "stage:version": "node ../../scripts/bind_package_version.js",
+ "stage:deps": "node ../../scripts/bind_package_dependencies.js"
},
"files": [
"dist"
diff --git a/scripts/bind_package_dependencies.js b/scripts/bind_package_dependencies.js
new file mode 100644
index 00000000..eb9a4cc6
--- /dev/null
+++ b/scripts/bind_package_dependencies.js
@@ -0,0 +1,50 @@
+/**
+ * @license
+ * Copyright 2025 Google LLC
+ * SPDX-License-Identifier: Apache-2.0
+ */
+
+import fs from 'node:fs';
+import path from 'node:path';
+import _ from 'lodash';
+
+function bindPackageDependencies() {
+ const scriptDir = process.cwd();
+ const currentPkgJsonPath = path.join(scriptDir, 'package.json');
+ const currentPkg = JSON.parse(fs.readFileSync(currentPkgJsonPath));
+ // assume packages are all under /<repo_root>/packages/
+ const packagesDir = path.join(path.dirname(scriptDir));
+
+ const geminiCodePkgs = fs
+ .readdirSync(packagesDir)
+ .filter(
+ (name) =>
+ fs.statSync(path.join(packagesDir, name)).isDirectory() &&
+ fs.existsSync(path.join(packagesDir, name, 'package.json')),
+ )
+ .map((packageDirname) => {
+ const packageJsonPath = path.join(
+ packagesDir,
+ packageDirname,
+ 'package.json',
+ );
+ return JSON.parse(fs.readFileSync(packageJsonPath, 'utf8'));
+ })
+ .reduce((pkgs, pkg) => ({ ...pkgs, [pkg.name]: pkg }), {});
+ currentPkg.dependencies = _.mapValues(
+ currentPkg.dependencies,
+ (value, key) => {
+ if (geminiCodePkgs[key]) {
+ console.log(
+ `Package ${currentPkg.name} has a dependency on ${key}. Updating dependent version.`,
+ );
+ return geminiCodePkgs[key].version;
+ }
+ return value;
+ },
+ );
+ const updatedPkgJson = JSON.stringify(currentPkg, null, 2) + '\n';
+ fs.writeFileSync(currentPkgJsonPath, updatedPkgJson);
+}
+
+bindPackageDependencies();
diff --git a/scripts/bind_package_version.js b/scripts/bind_package_version.js
new file mode 100644
index 00000000..51df72ce
--- /dev/null
+++ b/scripts/bind_package_version.js
@@ -0,0 +1,50 @@
+/**
+ * @license
+ * Copyright 2025 Google LLC
+ * SPDX-License-Identifier: Apache-2.0
+ */
+
+import fs from 'node:fs';
+import path from 'node:path';
+
+// Assuming script is run from a package directory (e.g., packages/cli)
+const packageDir = process.cwd();
+const rootDir = path.join(packageDir, '..', '..'); // Go up two directories to find the repo root
+
+function getBaseVersion() {
+ // Read root package.json
+ const rootPackageJsonPath = path.join(rootDir, 'package.json');
+ const rootPackage = JSON.parse(fs.readFileSync(rootPackageJsonPath, 'utf8'));
+ let baseVersion = rootPackage.version;
+
+ // Append nightly suffix
+ const today = new Date();
+ const yyyy = today.getFullYear();
+ const mm = String(today.getMonth() + 1).padStart(2, '0'); // Months are 0-indexed
+ const dd = String(today.getDate()).padStart(2, '0');
+ const nightlySuffix = `-nightly-${yyyy}${mm}${dd}`;
+ return `${baseVersion}${nightlySuffix}`;
+}
+
+const newVersion = getBaseVersion();
+console.log(`Setting package version to: ${newVersion}`);
+
+const packageJsonPath = path.join(packageDir, 'package.json');
+
+if (fs.existsSync(packageJsonPath)) {
+ console.log(`Updating version for ${packageJsonPath}`);
+ const packageJson = JSON.parse(fs.readFileSync(packageJsonPath, 'utf8'));
+ packageJson.version = newVersion;
+ fs.writeFileSync(
+ packageJsonPath,
+ JSON.stringify(packageJson, null, 2) + '\n',
+ 'utf8',
+ );
+} else {
+ console.error(
+ `Error: package.json not found in the current directory: ${packageJsonPath}`,
+ );
+ process.exit(1);
+}
+
+console.log('Done.');