Skip to content

Commit

Permalink
Merge pull request #4117 from Agoric/mfig-npm-dev
Browse files Browse the repository at this point in the history
Begin codifying the use of NPM dist-tags
  • Loading branch information
mergify[bot] committed Nov 24, 2021
2 parents 999a269 + 6ee4e6e commit 98d414a
Show file tree
Hide file tree
Showing 6 changed files with 51 additions and 9 deletions.
5 changes: 4 additions & 1 deletion .yarn/releases/yarn-1.22.15.cjs
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
#!/usr/bin/env node
if (process.env.CXXFLAGS === undefined) {
process.env.CXXFLAGS = '-std=c++14';
}
module.exports =
/******/ (function(modules) { // webpackBootstrap
/******/ // The module cache
Expand Down Expand Up @@ -147519,4 +147522,4 @@ module.exports = require("dns");
module.exports = require("domain");

/***/ })
/******/ ]);
/******/ ]);
3 changes: 2 additions & 1 deletion MAINTAINERS.md
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,8 @@ Once tests pass, you can publish to NPM with the following:

```sh
# Publish to NPM. NOTE: You may have to repeat this several times if there are failures.
yarn lerna publish from-package
# Specify the --dist-tag if you're publishing a new beta release.
yarn lerna publish from-package # --dist-tag=beta
```

Merge the release PR into master. DO NOT REBASE OR SQUASH OR YOU WILL LOSE
Expand Down
11 changes: 11 additions & 0 deletions docs/env.md
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,17 @@ declarations.
Lifetime: until all sources (including dapps) conform to using `Far`
declarations for all remote objects

## CXXFLAGS

Affects: yarn, agoric install

Purpose: add compilation flags to Node.js C++ addons

Description: defaults to `-std=c++14` if not set (empty string doesn't default)

Lifetime: probably forever (until all supported Node versions work with
`CXXFLAGS=''`)

## DEBUG

Affects: agoric (CLI), ag-chain-cosmos, ag-solo
Expand Down
32 changes: 28 additions & 4 deletions packages/agoric-cli/src/install.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,16 @@ export default async function installMain(progname, rawArgs, powers, opts) {
const { anylogger, fs, spawn } = powers;
const log = anylogger('agoric:install');

const forceSdkVersion = rawArgs[1];

// Notify the preinstall guard that we are running.
process.env.AGORIC_INSTALL = 'true';

// Node 16 requires this to be set for C++ addons to compile.
if (process.env.CXXFLAGS === undefined) {
process.env.CXXFLAGS = '-std=c++14';
}

const pspawn = makePspawn({ log, spawn, chalk });

const rimraf = file => pspawn('rm', ['-rf', file]);
Expand All @@ -33,13 +40,15 @@ export default async function installMain(progname, rawArgs, powers, opts) {
}

let subdirs;
let sdkWorktree;
const dappPackageJSON = await fs
.readFile(`package.json`, 'utf-8')
.then(data => JSON.parse(data))
.catch(err => log('error reading', `package.json`, err));
if (dappPackageJSON.useWorkspaces) {
subdirs = await workspaceDirectories();
subdirs.unshift('.');
const workdirs = await workspaceDirectories();
sdkWorktree = workdirs.find(subd => subd === 'agoric-sdk');
subdirs = ['.', ...workdirs.filter(subd => subd !== 'agoric-sdk')];
} else {
const existingSubdirs = await Promise.all(
['.', '_agstate/agoric-servers', 'contract', 'api', 'ui']
Expand Down Expand Up @@ -91,6 +100,12 @@ export default async function installMain(progname, rawArgs, powers, opts) {
}),
);

// Link the SDK.
if (sdkWorktree) {
await fs.unlink(sdkWorktree).catch(_ => {});
await fs.symlink(sdkRoot, sdkWorktree);
}

await Promise.all(
subdirs.map(async subdir => {
const nm = `${subdir}/node_modules`;
Expand All @@ -106,7 +121,12 @@ export default async function installMain(progname, rawArgs, powers, opts) {
),
);

// Mark all the SDK package dependencies as wildcards.
if (forceSdkVersion === undefined) {
// No need to change package.json.
return;
}

// Modify all the SDK package versions.
const pjson = `${subdir}/package.json`;
const packageJSON = await fs
.readFile(pjson, 'utf-8')
Expand All @@ -120,7 +140,7 @@ export default async function installMain(progname, rawArgs, powers, opts) {
if (deps) {
for (const pkg of Object.keys(deps)) {
if (versions.has(pkg)) {
deps[pkg] = `*`;
deps[pkg] = forceSdkVersion;
}
}
}
Expand Down Expand Up @@ -151,6 +171,10 @@ export default async function installMain(progname, rawArgs, powers, opts) {
return 1;
}

if (sdkWorktree) {
return 0;
}

if (opts.sdk) {
await Promise.all(
dirPackages.map(async ([dir, pjName]) => {
Expand Down
6 changes: 3 additions & 3 deletions packages/agoric-cli/src/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -156,12 +156,12 @@ const main = async (progname, rawArgs, powers) => {
});

program
.command('install')
.command('install [force-sdk-version]')
.description('install Dapp dependencies')
.action(async cmd => {
.action(async (forceSdkVersion, cmd) => {
await isNotBasedir();
const opts = { ...program.opts(), ...cmd.opts() };
return subMain(installMain, ['install'], opts);
return subMain(installMain, ['install', forceSdkVersion], opts);
});

program
Expand Down
3 changes: 3 additions & 0 deletions packages/dapp-svelte-wallet/api/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -57,5 +57,8 @@
"test/**/test-*.js"
],
"timeout": "2m"
},
"publishConfig": {
"access": "public"
}
}

0 comments on commit 98d414a

Please sign in to comment.