build-strap 5.0.0-dev.71 → 5.0.0-dev.77

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "build-strap",
3
- "version": "5.0.0-dev.71",
3
+ "version": "5.0.0-dev.77",
4
4
  "description": "Node scripts for building things",
5
5
  "license": "MIT",
6
6
  "authors": [
package/src/gh.d.ts CHANGED
@@ -1,7 +1,11 @@
1
1
  import { SpawnOptions } from './cp.js';
2
2
  export declare const gh: (args: string[], options?: SpawnOptions | undefined) => Promise<import("./cp.js").SpawnResult>;
3
3
  export declare const ghRepoClone: (repo: string, repoDir: string) => Promise<void>;
4
- export declare const ensureGhRepo: (repo: string, rootDir?: string) => Promise<void>;
4
+ export declare const ensureGhRepo: (repo: string, { rootDir, targetDir, targetName, }?: {
5
+ rootDir?: string | undefined;
6
+ targetDir?: string | undefined;
7
+ targetName?: string | undefined;
8
+ }) => Promise<void>;
5
9
  export declare const ensureGhAuthLogin: ({ host, scopes, }?: {
6
10
  host?: string | undefined;
7
11
  scopes?: string | undefined;
package/src/gh.js CHANGED
@@ -9,10 +9,11 @@ export const ghRepoClone = async (repo, repoDir) => {
9
9
  stdio: 'inherit',
10
10
  });
11
11
  };
12
- export const ensureGhRepo = async (repo, rootDir = '.') => {
13
- const repoDir = path.join(rootDir, repo);
12
+ export const ensureGhRepo = async (repo, { rootDir = '.', targetDir, targetName, } = {}) => {
13
+ const repoDir = targetDir ||
14
+ path.join(rootDir, targetName || repo.split('/').pop() || repo);
14
15
  if (!(await fs.pathExists(repoDir))) {
15
- buildLog(`${repo} not found, cloning...`);
16
+ buildLog(`${repo} not found, cloning into ${repoDir}...`);
16
17
  await ghRepoClone(repo, repoDir);
17
18
  }
18
19
  };
package/src/git.d.ts CHANGED
@@ -1,5 +1,6 @@
1
1
  import { SpawnOptions } from './cp.js';
2
- export declare const git: (args: string[], opts?: SpawnOptions | undefined) => Promise<string>;
2
+ export declare const git: (args: string[], opts?: SpawnOptions | undefined) => Promise<import("./cp.js").SpawnResult>;
3
+ export declare const gitOutput: (args: string[], opts?: SpawnOptions | undefined) => Promise<string>;
3
4
  export declare function gitBranch(): Promise<string>;
4
5
  export declare function gitRevId(): Promise<string>;
5
6
  declare type GitInfo = {
package/src/git.js CHANGED
@@ -1,14 +1,15 @@
1
1
  import { spawn } from './cp.js';
2
2
  import { userQuestion } from './prompt.js';
3
3
  import { buildLog } from './run.js';
4
- export const git = async (args, opts) => (await spawn('git', args, { captureOutput: true, ...opts })).stdout.trim();
4
+ export const git = async (args, opts) => spawn('git', args, opts);
5
+ export const gitOutput = async (args, opts) => (await git(args, { captureOutput: true, ...opts })).stdout.trim();
5
6
  export async function gitBranch() {
6
- return (await git(['symbolic-ref', '--short', 'HEAD']))
7
+ return (await gitOutput(['symbolic-ref', '--short', 'HEAD']))
7
8
  .replace(/[_+/]/g, '-')
8
9
  .trim();
9
10
  }
10
11
  export async function gitRevId() {
11
- return (await git(['rev-parse', '--short=12', 'HEAD']))
12
+ return (await gitOutput(['rev-parse', '--short=12', 'HEAD']))
12
13
  .replace(/[+]/g, '')
13
14
  .trim();
14
15
  }
@@ -23,9 +24,9 @@ export async function gitInfo(noCache = false) {
23
24
  return info;
24
25
  }
25
26
  export const ensureGitLfsInstalled = async () => {
26
- await git(['lfs', 'install'], { stdio: 'inherit' });
27
+ await git(['lfs', 'install']);
27
28
  };
28
- export const gitConfigRead = async (key, global = true) => git(['config', ...(global ? ['--global'] : []), key], {
29
+ export const gitConfigRead = async (key, global = true) => gitOutput(['config', ...(global ? ['--global'] : []), key], {
29
30
  rejectOnErrorCode: false,
30
31
  });
31
32
  export const gitConfigWrite = async (key, value, global = true) => {