Skip to content

Commit

Permalink
build: address issue with snapshot publishing due to non existing pro…
Browse files Browse the repository at this point in the history
…perty

This should fix the snpashot publishing which are currently being skipped.

```
Skipping @angular/cli.
Skipping @angular/create.
Skipping @angular/pwa.
Skipping @angular/ssr.
Skipping @angular-devkit/architect.
Skipping @angular-devkit/architect-cli.
Skipping @angular-devkit/build-angular.
Skipping @angular-devkit/build-webpack.
Skipping @angular-devkit/core.
Skipping @angular-devkit/schematics.
Skipping @angular-devkit/schematics-cli.
Skipping @ngtools/webpack.
Skipping @schematics/angular.
```
  • Loading branch information
alan-agius4 committed Mar 14, 2024
1 parent 7975845 commit 021a434
Showing 1 changed file with 8 additions and 8 deletions.
16 changes: 8 additions & 8 deletions scripts/snapshots.mts
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,8 @@ function _copy(from: string, to: string) {
});
}

const monorepoData = JSON.parse(fs.readFileSync('./.monorepo.json', 'utf-8'));

function _exec(command: string, args: string[], opts: { cwd?: string }) {
const { status, error, stdout } = spawnSync(command, args, {
stdio: ['ignore', 'pipe', 'inherit'],
Expand All @@ -65,29 +67,27 @@ function _exec(command: string, args: string[], opts: { cwd?: string }) {
return stdout.toString('utf-8');
}

const monorepoData = JSON.parse(fs.readFileSync('./.monorepo.json', 'utf-8'));
let gitShaCache: string | undefined;

async function _publishSnapshot(
pkg: PackageInfo,
branch: string,
message: string,
githubToken: string,
) {
const monoRepoPackageData = monorepoData[pkg.name];
if (!monoRepoPackageData || !monorepoData.snapshot) {
const snapshotRepo = monorepoData[pkg.name]?.snapshotRepo;
if (!snapshotRepo) {
console.warn(`Skipping ${pkg.name}.`);

return;
}

console.info(`Publishing ${pkg.name} to repo ${JSON.stringify(monorepoData.snapshotRepo)}.`);
console.info(`Publishing ${pkg.name} to repo ${snapshotRepo}.`);

const root = process.cwd();
console.debug('Temporary directory: ' + root);

const url = `https://${githubToken ? githubToken + '@' : ''}github.com/${monorepoData.snapshotRepo}.git`;
const destPath = path.join(root, path.basename(monorepoData.snapshotRepo));
const url = `https://${githubToken ? githubToken + '@' : ''}github.com/${snapshotRepo}.git`;
const destPath = path.join(root, path.basename(snapshotRepo));

_exec('git', ['clone', url], { cwd: root });
if (branch) {
Expand All @@ -113,7 +113,7 @@ async function _publishSnapshot(

// Add the header to the existing README.md (or create a README if it doesn't exist).
const readmePath = path.join(destPath, 'README.md');
let readme = readmeHeaderFn(pkg.name, monoRepoPackageData.snapshotRepo);
let readme = readmeHeaderFn(pkg.name, snapshotRepo);
try {
readme += fs.readFileSync(readmePath, 'utf-8');
} catch {}
Expand Down

0 comments on commit 021a434

Please sign in to comment.