Skip to content

Commit 81b230b

Browse files
merge master
2 parents aaa9adb + 7e52f2c commit 81b230b

File tree

109 files changed

+974
-654
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

109 files changed

+974
-654
lines changed

package.json

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,13 @@
4444
"oc"
4545
],
4646
"devDependencies": {
47+
"@types/errorhandler": "^1.5.0",
48+
"@types/express": "^4.17.13",
49+
"@types/morgan": "^1.9.3",
50+
"@types/multer": "^1.4.7",
51+
"@types/colors": "^1.2.1",
4752
"@types/node": "^16.9.6",
53+
"@types/semver": "^7.3.8",
4854
"@types/yargs": "^17.0.3",
4955
"@typescript-eslint/eslint-plugin": "^4.31.2",
5056
"@typescript-eslint/parser": "^4.31.2",

src/cli/commands.js renamed to src/cli/commands.ts

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,4 @@
1-
'use strict';
2-
3-
module.exports = {
1+
export default {
42
usage: 'Usage: $0 <command> [options]',
53
commands: {
64
clean: {

src/cli/domain/clean.js

Lines changed: 0 additions & 20 deletions
This file was deleted.

src/cli/domain/clean.ts

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
import async from 'async';
2+
import fs from 'fs-extra';
3+
import makeGetComponentsByDir from './get-components-by-dir';
4+
import path from 'path';
5+
6+
const getComponentsByDir = makeGetComponentsByDir();
7+
8+
export function fetchList(dirPath: string, callback: Callback<string[]>) {
9+
return getComponentsByDir(dirPath, (err, list) => {
10+
if (err) return (callback as any)(err);
11+
if (list.length === 0) return callback(null, []);
12+
13+
const toRemove = list.map(folder => path.join(folder, 'node_modules'));
14+
const folderExists = (folder, cb) =>
15+
fs.exists(folder, exists => cb(null, exists));
16+
17+
async.filterSeries(toRemove, folderExists, callback as any);
18+
});
19+
}
20+
21+
export function remove(list: string[], callback: Callback<string>) {
22+
return async.eachSeries(list, fs.remove, callback as any);
23+
}

src/cli/domain/get-components-by-dir.js renamed to src/cli/domain/get-components-by-dir.ts

Lines changed: 8 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,9 @@
1-
'use strict';
1+
import fs from 'fs-extra';
2+
import path from 'path';
23

3-
const fs = require('fs-extra');
4-
const path = require('path');
5-
const _ = require('lodash');
6-
7-
module.exports = function() {
8-
return function(componentsDir, callback) {
9-
const isOcComponent = function(file) {
4+
export default function getComponentsByDir() {
5+
return function(componentsDir: string, callback: Callback<string[]>) {
6+
const isOcComponent = function(file: string) {
107
const filePath = path.resolve(componentsDir, file),
118
packagePath = path.join(filePath, 'package.json');
129
let content;
@@ -23,10 +20,10 @@ module.exports = function() {
2320

2421
const packagedProperty = content.oc && content.oc.packaged;
2522

26-
return _.isUndefined(packagedProperty);
23+
return typeof packagedProperty === 'undefined';
2724
};
2825

29-
let dirContent;
26+
let dirContent: string[];
3027

3128
try {
3229
dirContent = fs.readdirSync(componentsDir);
@@ -40,4 +37,4 @@ module.exports = function() {
4037

4138
callback(null, components);
4239
};
43-
};
40+
}

src/cli/domain/get-mocked-plugins.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,8 @@ const fs = require('fs-extra');
44
const path = require('path');
55
const _ = require('lodash');
66

7-
const settings = require('../../resources/settings');
8-
const strings = require('../../resources/');
7+
const settings = require('../../resources/settings').default;
8+
const strings = require('../../resources/').default;
99

1010
const isMockValid = plugin => {
1111
const isFunction = _.isFunction(plugin);

src/cli/domain/handle-dependencies/ensure-compiler-is-declared-as-devDependency.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
'use strict';
22

3-
const strings = require('../../../resources');
3+
const strings = require('../../../resources').default;
44

55
module.exports = (options, cb) => {
66
const { componentPath, pkg, template } = options;

src/cli/domain/handle-dependencies/get-missing-dependencies.js

Lines changed: 0 additions & 17 deletions
This file was deleted.
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
import path from 'path';
2+
import moduleExists from '../../../utils/module-exists';
3+
4+
export default function getMissingDependencies(
5+
dependencies: Record<string, string> = {}
6+
) {
7+
const missing: string[] = [];
8+
9+
Object.entries(dependencies).forEach(([dependency, version]) => {
10+
const pathToModule = path.resolve('node_modules/', dependency);
11+
if (!moduleExists(pathToModule)) {
12+
missing.push(`${dependency}@${version || 'latest'}`);
13+
}
14+
});
15+
16+
return missing;
17+
}

src/cli/domain/handle-dependencies/index.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ const getCompiler = require('./get-compiler');
1111
const installMissingDependencies = require('./install-missing-dependencies');
1212
const linkMissingDependencies = require('./link-missing-dependencies');
1313
const isTemplateLegacy = require('../../../utils/is-template-legacy').default;
14-
const strings = require('../../../resources');
14+
const strings = require('../../../resources').default;
1515

1616
const getComponentPackageJson = (componentPath, cb) =>
1717
fs.readJson(path.join(componentPath, 'package.json'), cb);

0 commit comments

Comments
 (0)