@sasjs/cli 3.13.0 → 3.13.3

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.
@@ -69,7 +69,7 @@ var setConstants = function () { return __awaiter(void 0, void 0, void 0, functi
69
69
  buildDestinationJobsFolder = path_1.default.join(buildDestinationFolder, 'jobs');
70
70
  buildDestinationDbFolder = path_1.default.join(buildDestinationFolder, 'db');
71
71
  buildDestinationDocsFolder = path_1.default.join(buildDestinationFolder, 'docs');
72
- return [4 /*yield*/, (0, utils_1.getCliNodeModulePath)('@sasjs/core')];
72
+ return [4 /*yield*/, (0, utils_1.getNodeModulePath)('@sasjs/core')];
73
73
  case 2:
74
74
  macroCorePath = _d.sent();
75
75
  buildDestinationResultsFolder = (0, utils_2.getAbsolutePath)(buildResultsFolder, isLocal ? process.projectDir : homeDir);
@@ -78,7 +78,37 @@ describe('setConstants', function () {
78
78
  }
79
79
  });
80
80
  }); });
81
- test('should set constants inside appFolder', function () { return __awaiter(void 0, void 0, void 0, function () {
81
+ test('should set constants inside appFolder when @sasjs/core dependency is present', function () { return __awaiter(void 0, void 0, void 0, function () {
82
+ var appFolder, hasSasjsCore;
83
+ return __generator(this, function (_a) {
84
+ switch (_a.label) {
85
+ case 0:
86
+ appFolder = ['some', 'app', 'folder'].join(path_1.default.sep);
87
+ process.projectDir = appFolder;
88
+ jest
89
+ .spyOn(configUtils, 'getLocalOrGlobalConfig')
90
+ .mockImplementation(function () { return __awaiter(void 0, void 0, void 0, function () {
91
+ return __generator(this, function (_a) {
92
+ return [2 /*return*/, Promise.resolve({
93
+ configuration: config,
94
+ isLocal: true
95
+ })];
96
+ });
97
+ }); });
98
+ jest.spyOn(process, 'cwd').mockImplementation(function () { return appFolder; });
99
+ hasSasjsCore = true;
100
+ jest
101
+ .spyOn(fileModule, 'folderExists')
102
+ .mockImplementation(function (path) { return Promise.resolve(hasSasjsCore); });
103
+ return [4 /*yield*/, (0, setConstants_1.setConstants)()];
104
+ case 1:
105
+ _a.sent();
106
+ verifySasjsConstants(process.projectDir, hasSasjsCore);
107
+ return [2 /*return*/];
108
+ }
109
+ });
110
+ }); });
111
+ test('should set constants inside appFolder when @sasjs/core dependency is not present', function () { return __awaiter(void 0, void 0, void 0, function () {
82
112
  var appFolder;
83
113
  return __generator(this, function (_a) {
84
114
  switch (_a.label) {
@@ -98,7 +128,9 @@ describe('setConstants', function () {
98
128
  jest.spyOn(process, 'cwd').mockImplementation(function () { return appFolder; });
99
129
  jest
100
130
  .spyOn(fileModule, 'folderExists')
101
- .mockImplementation(function () { return Promise.resolve(true); });
131
+ .mockImplementation(function (folderPath) {
132
+ return Promise.resolve(folderPath !== path_1.default.join(appFolder, 'node_modules', '@sasjs', 'core'));
133
+ });
102
134
  return [4 /*yield*/, (0, setConstants_1.setConstants)()];
103
135
  case 1:
104
136
  _a.sent();
@@ -130,7 +162,8 @@ describe('setConstants', function () {
130
162
  });
131
163
  }); });
132
164
  });
133
- var verifySasjsConstants = function (appFolder) {
165
+ var verifySasjsConstants = function (appFolder, hasSasjsCore) {
166
+ if (hasSasjsCore === void 0) { hasSasjsCore = false; }
134
167
  var prefixAppFolder = appFolder !== null && appFolder !== void 0 ? appFolder : require('os').homedir();
135
168
  var sasjsConstants = process.sasjsConstants;
136
169
  expect(sasjsConstants.buildSourceFolder).toEqual(prefixAppFolder);
@@ -143,7 +176,9 @@ var verifySasjsConstants = function (appFolder) {
143
176
  expect(sasjsConstants.buildDestinationResultsFolder).toEqual([prefixAppFolder, 'sasjsresults'].join(path_1.default.sep));
144
177
  expect(sasjsConstants.buildDestinationResultsLogsFolder).toEqual([prefixAppFolder, 'sasjsresults', 'logs'].join(path_1.default.sep));
145
178
  expect(sasjsConstants.buildDestinationTestFolder).toEqual([prefixAppFolder, 'sasjsbuild', 'tests'].join(path_1.default.sep));
146
- var corePath = path_1.default.join('cli', 'node_modules', '@sasjs', 'core');
179
+ var corePath = hasSasjsCore
180
+ ? 'core'
181
+ : path_1.default.join('cli', 'node_modules', '@sasjs', 'core');
147
182
  if (appFolder) {
148
183
  expect(sasjsConstants.macroCorePath).toEqual(path_1.default.join(prefixAppFolder, 'node_modules', '@sasjs', corePath));
149
184
  }
@@ -43,4 +43,4 @@ export declare const terminateProcess: (status: number) => never;
43
43
  * @returns boolean
44
44
  */
45
45
  export declare const isSASjsProject: () => Promise<boolean>;
46
- export declare const getCliNodeModulePath: (module: string) => Promise<string>;
46
+ export declare const getNodeModulePath: (module: string) => Promise<string>;
@@ -86,7 +86,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
86
86
  return (mod && mod.__esModule) ? mod : { "default": mod };
87
87
  };
88
88
  Object.defineProperty(exports, "__esModule", { value: true });
89
- exports.getCliNodeModulePath = exports.isSASjsProject = exports.terminateProcess = exports.prefixAppLoc = exports.loadEnvVariables = exports.displaySasjsRunnerError = exports.getAdapterInstance = exports.checkNodeVersion = exports.millisecondsToDdHhMmSs = exports.arrToObj = exports.parseLogLines = exports.executeShellScript = exports.getUniqServicesObj = exports.removeComments = exports.setupDoxygen = exports.setupGhooks = exports.setupGitIgnore = exports.setupNpmProject = exports.createTemplateApp = exports.createMinimalApp = exports.createAngularApp = exports.createReactApp = exports.diff = exports.inExistingProject = void 0;
89
+ exports.getNodeModulePath = exports.isSASjsProject = exports.terminateProcess = exports.prefixAppLoc = exports.loadEnvVariables = exports.displaySasjsRunnerError = exports.getAdapterInstance = exports.checkNodeVersion = exports.millisecondsToDdHhMmSs = exports.arrToObj = exports.parseLogLines = exports.executeShellScript = exports.getUniqServicesObj = exports.removeComments = exports.setupDoxygen = exports.setupGhooks = exports.setupGitIgnore = exports.setupNpmProject = exports.createTemplateApp = exports.createMinimalApp = exports.createAngularApp = exports.createReactApp = exports.diff = exports.inExistingProject = void 0;
90
90
  var shelljs_1 = __importDefault(require("shelljs"));
91
91
  var path_1 = __importDefault(require("path"));
92
92
  var ora_1 = __importDefault(require("ora"));
@@ -208,7 +208,7 @@ function createApp(folderPath, repoUrl, installDependencies) {
208
208
  if (installDependencies) {
209
209
  spinner.text = 'Installing dependencies...';
210
210
  spinner.start();
211
- shelljs_1.default.exec("cd \"".concat(folderPath, "\" && npm install"), {
211
+ shelljs_1.default.exec("cd \"".concat(folderPath, "\" && git init && npm install"), {
212
212
  silent: true
213
213
  });
214
214
  spinner.stop();
@@ -605,24 +605,36 @@ var isSASjsProject = function () { return __awaiter(void 0, void 0, void 0, func
605
605
  });
606
606
  }); };
607
607
  exports.isSASjsProject = isSASjsProject;
608
- var getCliNodeModulePath = function (module) { return __awaiter(void 0, void 0, void 0, function () {
609
- var cliDepsPath, localPath, globalPath;
608
+ var getNodeModulePath = function (module) { return __awaiter(void 0, void 0, void 0, function () {
609
+ var projectPath, cliDepsPath, cliLocalPath, cliGlobalPath;
610
610
  return __generator(this, function (_a) {
611
611
  switch (_a.label) {
612
612
  case 0:
613
- cliDepsPath = path_1.default.join('@sasjs', 'cli', 'node_modules');
614
- localPath = path_1.default.join(process.cwd(), 'node_modules', cliDepsPath, module);
615
- return [4 /*yield*/, (0, utils_1.folderExists)(localPath)];
613
+ projectPath = path_1.default.join(process.cwd(), 'node_modules', module);
614
+ return [4 /*yield*/, (0, utils_1.folderExists)(projectPath)];
616
615
  case 1:
617
616
  if (_a.sent())
618
- return [2 /*return*/, localPath];
619
- globalPath = path_1.default.join(shelljs_1.default.exec("npm root -g", { silent: true }).stdout.replace(/\n/, ''), cliDepsPath, module);
620
- return [4 /*yield*/, (0, utils_1.folderExists)(globalPath)];
617
+ return [2 /*return*/, projectPath
618
+ // Check if module is present in @sasjs/cli located in project's dependencies
619
+ ];
620
+ cliDepsPath = path_1.default.join('@sasjs', 'cli', 'node_modules');
621
+ cliLocalPath = path_1.default.join(process.cwd(), 'node_modules', cliDepsPath, module);
622
+ return [4 /*yield*/, (0, utils_1.folderExists)(cliLocalPath)];
621
623
  case 2:
622
624
  if (_a.sent())
623
- return [2 /*return*/, globalPath];
625
+ return [2 /*return*/, cliLocalPath
626
+ // Check if module is present in global @sasjs/cli
627
+ ];
628
+ cliGlobalPath = path_1.default.join(shelljs_1.default.exec("npm root -g", { silent: true }).stdout.replace(/\n/, ''), cliDepsPath, module);
629
+ return [4 /*yield*/, (0, utils_1.folderExists)(cliGlobalPath)];
630
+ case 3:
631
+ if (_a.sent())
632
+ return [2 /*return*/, cliGlobalPath
633
+ // Return default value
634
+ ];
635
+ // Return default value
624
636
  return [2 /*return*/, ''];
625
637
  }
626
638
  });
627
639
  }); };
628
- exports.getCliNodeModulePath = getCliNodeModulePath;
640
+ exports.getNodeModulePath = getNodeModulePath;
package/package.json CHANGED
@@ -48,7 +48,7 @@
48
48
  },
49
49
  "dependencies": {
50
50
  "@sasjs/adapter": "3.8.5",
51
- "@sasjs/core": "4.18.11",
51
+ "@sasjs/core": "4.18.15",
52
52
  "@sasjs/lint": "1.11.2",
53
53
  "@sasjs/utils": "2.42.0",
54
54
  "chalk": "4.1.2",
@@ -93,5 +93,5 @@
93
93
  "typescript": "4.5.4",
94
94
  "util": "0.12.4"
95
95
  },
96
- "version": "3.13.0"
96
+ "version": "3.13.3"
97
97
  }