build-strap 6.1.0-main.167 → 6.1.0-main.168

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -10,13 +10,41 @@ This project builds itself, so take a look in the `targets/` folder for an examp
10
10
  [![devDependencies](https://img.shields.io/david/dev/murrayju/build-strap.svg)](https://david-dm.org/murrayju/build-strap?type=dev)
11
11
 
12
12
  ## Create a "zero dependency" bootstrapped build
13
- You can set up your project to build with (practically) no pre-requisite dependencies.
14
- - Copy the [build-strap-cli](https://github.com/murrayju/build-strap-cli/) into the root of your project.
13
+ You can set up your project to build with (practically) no pre-requisite dependencies. [nub-strap](https://github.com/murrayju/nub-strap/) downloads a pinned version of [nub](https://nubjs.com) into the project. Nub then provides the pinned versions of node and yarn.
14
+ - Copy the `nub` script from nub-strap into the root of your project, and pin the nub version in it.
15
15
 
16
16
  ```
17
- curl -o bs https://raw.githubusercontent.com/murrayju/build-strap-cli/master/bs && chmod +x bs
18
- curl -o bs.ps1 https://raw.githubusercontent.com/murrayju/build-strap-cli/master/bs.ps1
19
- curl -o bs.bat https://raw.githubusercontent.com/murrayju/build-strap-cli/master/bs.bat
17
+ curl -o nub https://raw.githubusercontent.com/murrayju/nub-strap/main/nub && chmod +x nub
18
+ ```
19
+
20
+ - Pin the node and yarn versions in your `package.json`.
21
+
22
+ ```
23
+ {
24
+ "devEngines": {
25
+ "runtime": { "name": "node", "version": "24.18.0" }
26
+ },
27
+ "packageManager": "yarn@1.22.22"
28
+ }
29
+ ```
30
+
31
+ - Add a `yarn` script, which runs the pinned yarn with nub.
32
+
33
+ ```
34
+ #!/bin/bash
35
+ set -euo pipefail
36
+
37
+ yarnJs=$(./nub pm which)
38
+ exec ./nub --node "$yarnJs" "$@"
39
+ ```
40
+
41
+ - Add a `bs` script, which installs dependencies and runs your build targets.
42
+
43
+ ```
44
+ #!/bin/bash
45
+
46
+ ./yarn install
47
+ exec ./nub ./targets/run.ts "$@"
20
48
  ```
21
49
 
22
50
  ## Add the dependency reference
@@ -32,8 +60,6 @@ By default, the build tools read project-specific configuration from your `packa
32
60
  "name": "your-project-name",
33
61
  "version": "1.2.3",
34
62
  "buildStrap": {
35
- "nodeVersion": "24.18.0",
36
- "yarnVersion": "1.22.22",
37
63
  "repoType": "git",
38
64
  "copyright": "your company",
39
65
  "mainBranch": "main",
@@ -94,7 +120,7 @@ setPkg(pkg);
94
120
  ### runCli
95
121
  Useful when building your own build from scratch. Helps to interpret CLI arguments and invoke js files as build targets. Uses `buildLog` to timestamp everything.
96
122
 
97
- This example should serve as your entrypoint (from `yarn run`).
123
+ This example should serve as your entrypoint (for example, `./nub ./targets/run.ts`).
98
124
  ```
99
125
  import { run, runCli, setPkg } from 'build-strap';
100
126
  import pkg from '../package.json';
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "build-strap",
3
- "version": "6.1.0-main.167",
3
+ "version": "6.1.0-main.168",
4
4
  "description": "Node scripts for building things",
5
5
  "license": "MIT",
6
6
  "author": "Justin Murray <justin@murrayju.com>",
package/src/npm.js CHANGED
@@ -11,7 +11,8 @@ export function getNpmConfig() {
11
11
  export const envNpmCreds = (process.env.NPM_CREDS && JSON.parse(process.env.NPM_CREDS)) || null;
12
12
  const npmExe = (npmPath) => npmPath || (platform() === 'win32' ? 'npm.cmd' : 'npm');
13
13
  export async function npm({ args = [], npmPath, spawnOptions, } = {}) {
14
- const localNpm = path.join(path.dirname(process.execPath), 'lib/node_modules/npm/bin/npm-cli.js');
14
+ // The node distribution puts npm next to the node binary.
15
+ const localNpm = path.join(path.dirname(process.execPath), platform() === 'win32' ? '' : '../lib', 'node_modules/npm/bin/npm-cli.js');
15
16
  const spawnOpts = {
16
17
  env: process.env,
17
18
  shell: true,
package/src/pkg.d.ts CHANGED
@@ -21,10 +21,12 @@ export interface PackageJson {
21
21
  dependencies?: Record<string, string>;
22
22
  description?: string;
23
23
  devDependencies?: Record<string, string>;
24
+ devEngines?: Record<string, unknown>;
24
25
  engines?: Record<string, string>;
25
26
  license?: string;
26
27
  main?: string;
27
28
  name: string;
29
+ packageManager?: string;
28
30
  peerDependencies?: Record<string, string>;
29
31
  private?: boolean;
30
32
  repository?: string | {
package/src/yarn.js CHANGED
@@ -15,11 +15,15 @@ export async function yarn({ args = [], spawnOptions, } = {}) {
15
15
  stdio: 'inherit',
16
16
  ...spawnOptions,
17
17
  };
18
+ const projectYarn = path.resolve('yarn');
18
19
  return (await fs.pathExists(localYarn))
19
20
  ? // prefer to use local copy of yarn
20
21
  spawn(process.execPath, [localYarn, ...args], spawnOpts)
21
- : // fall back to globally installed yarn
22
- spawn('yarn', args, spawnOpts);
22
+ : (await fs.pathExists(projectYarn))
23
+ ? // use the yarn wrapper script of the project (for example, with nub)
24
+ spawn(projectYarn, args, spawnOpts)
25
+ : // fall back to globally installed yarn
26
+ spawn('yarn', args, spawnOpts);
23
27
  }
24
28
  export const yarnFiles = ['./package.json', './yarn.lock'];
25
29
  // Smart yarn invocation, only if package changed