oclif 4.1.0 → 4.1.1

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.
@@ -22,6 +22,39 @@ const pack = async (from, to) => {
22
22
  ? await exec(`tar czf ${to} ${path.basename(from)}`, { cwd })
23
23
  : await exec(`tar cfJ ${to} ${path.basename(from)}`, { cwd });
24
24
  };
25
+ const isYarnProject = (yarnRootPath) => {
26
+ const yarnLockFileName = 'yarn.lock';
27
+ const rootYarnLockFilePath = path.join(yarnRootPath, yarnLockFileName);
28
+ return (0, node_fs_1.existsSync)(rootYarnLockFilePath);
29
+ };
30
+ const copyCoreYarnFiles = async (yarnRootPath, workspacePath) => {
31
+ // copy yarn dependencies lock file
32
+ const yarnLockFileName = 'yarn.lock';
33
+ const rootYarnLockFilePath = path.join(yarnRootPath, yarnLockFileName);
34
+ const workspaceYarnLockFilePath = path.join(workspacePath, yarnLockFileName);
35
+ if ((0, node_fs_1.existsSync)(rootYarnLockFilePath)) {
36
+ await (0, fs_extra_1.copy)(rootYarnLockFilePath, workspaceYarnLockFilePath);
37
+ }
38
+ // copy yarn configuration file
39
+ const yarnConfigFileName = '.yarnrc.yml';
40
+ const rootYarnConfigFilePath = path.join(yarnRootPath, yarnConfigFileName);
41
+ const workspaceYarnConfigFilePath = path.join(workspacePath, yarnConfigFileName);
42
+ if ((0, node_fs_1.existsSync)(rootYarnConfigFilePath)) {
43
+ await (0, fs_extra_1.copy)(rootYarnConfigFilePath, workspaceYarnConfigFilePath);
44
+ }
45
+ // copy yarn releases e.g. yarn may be installed via a local config path like "yarnPath"
46
+ const yarnReleasesDirectoryRelativePath = './.yarn/releases/';
47
+ const rootYarnReleasesDirectoryPath = path.join(yarnRootPath, yarnReleasesDirectoryRelativePath);
48
+ const workspaceYarnReleasesDirectoryPath = path.join(workspacePath, yarnReleasesDirectoryRelativePath);
49
+ if ((0, node_fs_1.existsSync)(rootYarnReleasesDirectoryPath)) {
50
+ // create the directory if it does not exist
51
+ if (!(0, node_fs_1.existsSync)(workspaceYarnReleasesDirectoryPath)) {
52
+ await (0, promises_1.mkdir)(workspaceYarnReleasesDirectoryPath, { recursive: true });
53
+ }
54
+ // recursively copy all files in the directory
55
+ await (0, fs_extra_1.copy)(rootYarnReleasesDirectoryPath, workspaceYarnReleasesDirectoryPath);
56
+ }
57
+ };
25
58
  async function build(c, options = {}) {
26
59
  const { config, xz } = c;
27
60
  const packCLI = async () => {
@@ -52,8 +85,8 @@ async function build(c, options = {}) {
52
85
  };
53
86
  const addDependencies = async () => {
54
87
  const yarnRoot = findYarnWorkspaceRoot(c.root) || c.root;
55
- if ((0, node_fs_1.existsSync)(path.join(yarnRoot, 'yarn.lock'))) {
56
- await (0, fs_extra_1.copy)(path.join(yarnRoot, 'yarn.lock'), path.join(c.workspace(), 'yarn.lock'));
88
+ if (isYarnProject(yarnRoot)) {
89
+ await copyCoreYarnFiles(yarnRoot, c.workspace());
57
90
  const { stdout } = await exec('yarn -v');
58
91
  const yarnVersion = stdout.charAt(0);
59
92
  if (yarnVersion === '1') {
@@ -717,5 +717,5 @@
717
717
  ]
718
718
  }
719
719
  },
720
- "version": "4.1.0"
720
+ "version": "4.1.1"
721
721
  }
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "oclif",
3
3
  "description": "oclif: create your own CLI",
4
- "version": "4.1.0",
4
+ "version": "4.1.1",
5
5
  "author": "Salesforce",
6
6
  "bin": {
7
7
  "oclif": "bin/run.js"