@goldstack/utils-yarn 0.3.46 → 0.4.0

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
@@ -1,5 +1,5 @@
1
- # Goldstack Yarn Utilities
2
-
3
- This library allows running [yarn](https://yarnpkg.com/) commands from Node.js applications.
4
-
5
- See [utilsYarn.ts](https://github.com/goldstack/goldstack/blob/master/workspaces/templates-lib/packages/utils-yarn/src/utilsYarn.ts).
1
+ # Goldstack Yarn Utilities
2
+
3
+ This library allows running [yarn](https://yarnpkg.com/) commands from Node.js applications.
4
+
5
+ See [utilsYarn.ts](https://github.com/goldstack/goldstack/blob/master/workspaces/templates-lib/packages/utils-yarn/src/utilsYarn.ts).
@@ -1,15 +1,15 @@
1
- export declare const hasYarn: () => boolean;
2
- export declare const assertYarn: () => void;
3
- /**
4
- * Ensure that templates can be built in a CI environment, see
5
- * https://github.com/goldstack/goldstack/issues/41#issuecomment-1007857278
6
- *
7
- * @param projectDir
8
- * @param globalDir
9
- */
10
- export declare const configureForTemplateBuild: (projectDir: string, globalDir: string) => void;
11
- export interface YarnRunOptions {
12
- preferDocker?: boolean;
13
- }
14
- export declare const yarn: (dir: string, args: string, options?: YarnRunOptions) => void;
1
+ export declare const hasYarn: () => boolean;
2
+ export declare const assertYarn: () => void;
3
+ /**
4
+ * Ensure that templates can be built in a CI environment, see
5
+ * https://github.com/goldstack/goldstack/issues/41#issuecomment-1007857278
6
+ *
7
+ * @param projectDir
8
+ * @param globalDir
9
+ */
10
+ export declare const configureForTemplateBuild: (projectDir: string, globalDir: string) => void;
11
+ export interface YarnRunOptions {
12
+ preferDocker?: boolean;
13
+ }
14
+ export declare const yarn: (dir: string, args: string, options?: YarnRunOptions) => void;
15
15
  //# sourceMappingURL=utilsYarn.d.ts.map
@@ -1,74 +1,74 @@
1
- "use strict";
2
- var __importDefault = (this && this.__importDefault) || function (mod) {
3
- return (mod && mod.__esModule) ? mod : { "default": mod };
4
- };
5
- Object.defineProperty(exports, "__esModule", { value: true });
6
- exports.yarn = exports.configureForTemplateBuild = exports.assertYarn = exports.hasYarn = void 0;
7
- const utils_sh_1 = require("@goldstack/utils-sh");
8
- const utils_docker_1 = require("@goldstack/utils-docker");
9
- const path_1 = __importDefault(require("path"));
10
- const hasYarn = () => {
11
- if (!(0, utils_sh_1.commandExists)('yarn')) {
12
- return false;
13
- }
14
- else {
15
- return true;
16
- }
17
- };
18
- exports.hasYarn = hasYarn;
19
- const assertYarn = () => {
20
- if (!(0, utils_sh_1.commandExists)('yarn')) {
21
- throw new Error('Yarn must be installed. Please install yarn.');
22
- }
23
- };
24
- exports.assertYarn = assertYarn;
25
- /**
26
- * Ensure that templates can be built in a CI environment, see
27
- * https://github.com/goldstack/goldstack/issues/41#issuecomment-1007857278
28
- *
29
- * @param projectDir
30
- * @param globalDir
31
- */
32
- const configureForTemplateBuild = (projectDir, globalDir) => {
33
- console.log('Perform Yarn config overwrite for template building:');
34
- (0, exports.yarn)(projectDir, `config set globalFolder ${globalDir}`);
35
- (0, exports.yarn)(projectDir, 'config set checksumBehavior update');
36
- (0, exports.yarn)(projectDir, 'config set enableImmutableInstalls false');
37
- (0, exports.yarn)(projectDir, 'config set enableImmutableCache false');
38
- (0, exports.yarn)(projectDir, 'config');
39
- };
40
- exports.configureForTemplateBuild = configureForTemplateBuild;
41
- const execWithDocker = (dir, args) => {
42
- (0, utils_docker_1.assertDocker)();
43
- (0, utils_sh_1.exec)('docker run --rm ' +
44
- `-v "${path_1.default.resolve(dir)}":/app ` +
45
- '--workdir /app ' +
46
- (0, utils_docker_1.renderHostEnvironmentVariables)() +
47
- ' ' +
48
- `${(0, utils_docker_1.imageNodeYarn)()} ` +
49
- `yarn ${args}`);
50
- };
51
- const execWithCli = (dir, args) => {
52
- (0, exports.assertYarn)();
53
- const currentWorkDir = (0, utils_sh_1.pwd)();
54
- (0, utils_sh_1.cd)(path_1.default.resolve(dir));
55
- try {
56
- (0, utils_sh_1.exec)(`yarn ${args}`);
57
- }
58
- finally {
59
- (0, utils_sh_1.cd)(currentWorkDir);
60
- }
61
- };
62
- const yarn = (dir, args, options) => {
63
- // always prefer to run with cli
64
- if ((0, exports.hasYarn)() && !(options === null || options === void 0 ? void 0 : options.preferDocker)) {
65
- execWithCli(dir, args);
66
- return;
67
- }
68
- if (!(0, utils_docker_1.hasDocker)()) {
69
- throw new Error('Either yarn needs to be installed locally or Docker be available. Please install either yarn or Docker.');
70
- }
71
- execWithDocker(dir, args);
72
- };
73
- exports.yarn = yarn;
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ exports.yarn = exports.configureForTemplateBuild = exports.assertYarn = exports.hasYarn = void 0;
7
+ const utils_sh_1 = require("@goldstack/utils-sh");
8
+ const utils_docker_1 = require("@goldstack/utils-docker");
9
+ const path_1 = __importDefault(require("path"));
10
+ const hasYarn = () => {
11
+ if (!(0, utils_sh_1.commandExists)('yarn')) {
12
+ return false;
13
+ }
14
+ else {
15
+ return true;
16
+ }
17
+ };
18
+ exports.hasYarn = hasYarn;
19
+ const assertYarn = () => {
20
+ if (!(0, utils_sh_1.commandExists)('yarn')) {
21
+ throw new Error('Yarn must be installed. Please install yarn.');
22
+ }
23
+ };
24
+ exports.assertYarn = assertYarn;
25
+ /**
26
+ * Ensure that templates can be built in a CI environment, see
27
+ * https://github.com/goldstack/goldstack/issues/41#issuecomment-1007857278
28
+ *
29
+ * @param projectDir
30
+ * @param globalDir
31
+ */
32
+ const configureForTemplateBuild = (projectDir, globalDir) => {
33
+ console.log('Perform Yarn config overwrite for template building:');
34
+ (0, exports.yarn)(projectDir, `config set globalFolder ${globalDir}`);
35
+ (0, exports.yarn)(projectDir, 'config set checksumBehavior update');
36
+ (0, exports.yarn)(projectDir, 'config set enableImmutableInstalls false');
37
+ (0, exports.yarn)(projectDir, 'config set enableImmutableCache false');
38
+ (0, exports.yarn)(projectDir, 'config');
39
+ };
40
+ exports.configureForTemplateBuild = configureForTemplateBuild;
41
+ const execWithDocker = (dir, args) => {
42
+ (0, utils_docker_1.assertDocker)();
43
+ (0, utils_sh_1.exec)('docker run --rm ' +
44
+ `-v "${path_1.default.resolve(dir)}":/app ` +
45
+ '--workdir /app ' +
46
+ (0, utils_docker_1.renderHostEnvironmentVariables)() +
47
+ ' ' +
48
+ `${(0, utils_docker_1.imageNodeYarn)()} ` +
49
+ `yarn ${args}`);
50
+ };
51
+ const execWithCli = (dir, args) => {
52
+ (0, exports.assertYarn)();
53
+ const currentWorkDir = (0, utils_sh_1.pwd)();
54
+ (0, utils_sh_1.cd)(path_1.default.resolve(dir));
55
+ try {
56
+ (0, utils_sh_1.exec)(`yarn ${args}`);
57
+ }
58
+ finally {
59
+ (0, utils_sh_1.cd)(currentWorkDir);
60
+ }
61
+ };
62
+ const yarn = (dir, args, options) => {
63
+ // always prefer to run with cli
64
+ if ((0, exports.hasYarn)() && !(options === null || options === void 0 ? void 0 : options.preferDocker)) {
65
+ execWithCli(dir, args);
66
+ return;
67
+ }
68
+ if (!(0, utils_docker_1.hasDocker)()) {
69
+ throw new Error('Either yarn needs to be installed locally or Docker be available. Please install either yarn or Docker.');
70
+ }
71
+ execWithDocker(dir, args);
72
+ };
73
+ exports.yarn = yarn;
74
74
  //# sourceMappingURL=utilsYarn.js.map
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@goldstack/utils-yarn",
3
- "version": "0.3.46",
3
+ "version": "0.4.0",
4
4
  "description": "Easily run yarn commands from within JavaScript code",
5
5
  "keywords": [
6
6
  "goldstack",
@@ -35,11 +35,11 @@
35
35
  "version:apply:force": "yarn version $@ && yarn version apply"
36
36
  },
37
37
  "dependencies": {
38
- "@goldstack/utils-docker": "0.3.42",
39
- "@goldstack/utils-sh": "0.4.35"
38
+ "@goldstack/utils-docker": "0.4.0",
39
+ "@goldstack/utils-sh": "0.5.0"
40
40
  },
41
41
  "devDependencies": {
42
- "@goldstack/utils-git": "0.1.37",
42
+ "@goldstack/utils-git": "0.2.0",
43
43
  "@types/jest": "^28.1.8",
44
44
  "@types/node": "^18.7.13",
45
45
  "jest": "^28.1.0",