Skip to content
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

fix pack #1536

Closed
wants to merge 3 commits into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
52 changes: 9 additions & 43 deletions scripts/release-cli.ts
Original file line number Diff line number Diff line change
@@ -1,18 +1,10 @@
import { createExportableManifest } from '@pnpm/exportable-manifest';
import { readProjectManifest } from '@pnpm/read-project-manifest';
import { writeProjectManifest } from '@pnpm/write-project-manifest';
import { execFile, exec as execRaw } from 'child_process';
import { Octokit } from '@octokit/core';
import fs from 'fs';
import * as util from 'util';
const exec = util.promisify(execRaw);

const PATH_TO_CLI = process.cwd() + '/cli';
const PATH_TO_CLIENT = process.cwd() + '/packages/client';
const PATH_TO_CODEGEN = process.cwd() + '/packages/codegen';
const PATH_TO_IMPORTER = process.cwd() + '/packages/importer';
const PATH_TO_PGROLL = process.cwd() + '/packages/pgroll';

const base = {
owner: 'xataio',
repo: 'client-ts',
Expand Down Expand Up @@ -49,46 +41,20 @@ async function main() {

const operatingSystem = matrixToOclif(process.env.MATRIX_OS);

const { manifest, fileName } = await readProjectManifest(PATH_TO_CLI);
const {
manifest: { version: clientVersion }
} = await readProjectManifest(PATH_TO_CLIENT);
const {
manifest: { version: codegenVersion }
} = await readProjectManifest(PATH_TO_CODEGEN);
const {
manifest: { version: importerVersion }
} = await readProjectManifest(PATH_TO_IMPORTER);
const {
manifest: { version: pgrollVersion }
} = await readProjectManifest(PATH_TO_PGROLL);

if (!clientVersion || !codegenVersion || !importerVersion || !pgrollVersion)
throw new Error('Missing package versions.');

// Assume changeset version has been called and all the
// versions in package jsons are up to date

const workspaceProtocolPackageManifest = await createExportableManifest(PATH_TO_CLI, {
...manifest,
dependencies: {
...manifest.dependencies,
'@xata.io/client': clientVersion,
'@xata.io/codegen': codegenVersion,
'@xata.io/importer': importerVersion,
'@xata.io/pgroll': pgrollVersion
}
});
const PATH_TO_CLI = process.cwd() + '/cli';
const { manifest } = await readProjectManifest(PATH_TO_CLI);

await writeProjectManifest(`${PATH_TO_CLI}/${fileName}`, workspaceProtocolPackageManifest);
// Oclif pack expects a npm-shrinkwrap.json file and errors if it is not present.
execFile('rm', ['-rf', `${PATH_TO_CLI}/npm-shrinkwrap.json`]);

process.chdir(PATH_TO_CLI);

// Oclif pack expects a npm-shrinkwrap.json file and errors if it is not present.
execFile('rm', ['-rf', `${PATH_TO_CLI}/npm-shrinkwrap.json`]);
execFile('touch', [`${PATH_TO_CLI}/npm-shrinkwrap.json`]);
await exec(`pnpm ls --prod --json >> npm-shrinkwrap.json`);

// Build tarball with pnpm. Oclif uses npm which fails
await exec(`pnpm pack`);

await exec(`pnpm oclif pack ${operatingSystem}`);
await exec(`pnpm oclif pack ${operatingSystem} -t xata.io-cli-${manifest.version}.tgz`);

const octokit = new Octokit({
auth: process.env.GITHUB_TOKEN
Expand Down
Loading