@dittowords/cli 4.4.0 → 4.5.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/.github/actions/install-node-dependencies/action.yml +24 -0
- package/.github/workflows/required-checks.yml +24 -0
- package/__mocks__/fs.js +2 -0
- package/bin/__mocks__/api.js +48 -0
- package/bin/__mocks__/api.js.map +1 -0
- package/bin/config.js +6 -4
- package/bin/config.js.map +1 -1
- package/bin/config.test.js +4 -3
- package/bin/config.test.js.map +1 -1
- package/bin/consts.js +19 -29
- package/bin/consts.js.map +1 -1
- package/bin/generate-suggestions.js +68 -58
- package/bin/generate-suggestions.js.map +1 -1
- package/bin/generate-suggestions.test.js +24 -13
- package/bin/generate-suggestions.test.js.map +1 -1
- package/bin/http/__mocks__/fetchComponentFolders.js +71 -0
- package/bin/http/__mocks__/fetchComponentFolders.js.map +1 -0
- package/bin/http/__mocks__/fetchComponents.js +73 -0
- package/bin/http/__mocks__/fetchComponents.js.map +1 -0
- package/bin/http/__mocks__/fetchVariants.js +71 -0
- package/bin/http/__mocks__/fetchVariants.js.map +1 -0
- package/bin/http/fetchComponentFolders.js +4 -4
- package/bin/http/fetchComponentFolders.js.map +1 -1
- package/bin/http/fetchComponents.js +4 -4
- package/bin/http/fetchComponents.js.map +1 -1
- package/bin/http/fetchVariants.js +2 -2
- package/bin/http/fetchVariants.js.map +1 -1
- package/bin/http/http.test.js +159 -0
- package/bin/http/http.test.js.map +1 -0
- package/bin/http/importComponents.js +9 -2
- package/bin/http/importComponents.js.map +1 -1
- package/bin/init/project.test.js +5 -28
- package/bin/init/project.test.js.map +1 -1
- package/bin/init/token.js +72 -27
- package/bin/init/token.js.map +1 -1
- package/bin/init/token.test.js +87 -9
- package/bin/init/token.test.js.map +1 -1
- package/bin/pull-lib.test.js +379 -0
- package/bin/pull-lib.test.js.map +1 -0
- package/bin/pull.js +13 -5
- package/bin/pull.js.map +1 -1
- package/bin/pull.test.js +100 -289
- package/bin/pull.test.js.map +1 -1
- package/bin/replace.js +22 -6
- package/bin/replace.js.map +1 -1
- package/bin/replace.test.js +53 -11
- package/bin/replace.test.js.map +1 -1
- package/bin/types.js +2 -2
- package/bin/types.js.map +1 -1
- package/bin/utils/determineModuleType.js +6 -7
- package/bin/utils/determineModuleType.js.map +1 -1
- package/bin/utils/determineModuleType.test.js +60 -0
- package/bin/utils/determineModuleType.test.js.map +1 -0
- package/bin/utils/getSelectedProjects.js +5 -5
- package/bin/utils/getSelectedProjects.js.map +1 -1
- package/bin/utils/quit.js +3 -3
- package/bin/utils/quit.js.map +1 -1
- package/jest.config.ts +16 -0
- package/lib/__mocks__/api.ts +12 -0
- package/lib/config.test.ts +3 -1
- package/lib/config.ts +4 -2
- package/lib/consts.ts +19 -17
- package/lib/generate-suggestions.test.ts +23 -11
- package/lib/generate-suggestions.ts +89 -79
- package/lib/http/__mocks__/fetchComponentFolders.ts +23 -0
- package/lib/http/__mocks__/fetchComponents.ts +24 -0
- package/lib/http/__mocks__/fetchVariants.ts +21 -0
- package/lib/http/fetchComponentFolders.ts +6 -4
- package/lib/http/fetchComponents.ts +5 -3
- package/lib/http/fetchVariants.ts +14 -3
- package/lib/http/http.test.ts +122 -0
- package/lib/http/importComponents.ts +8 -0
- package/lib/init/project.test.ts +4 -27
- package/lib/init/token.test.ts +55 -7
- package/lib/init/token.ts +76 -27
- package/lib/pull-lib.test.ts +367 -0
- package/lib/pull.test.ts +97 -310
- package/lib/pull.ts +11 -3
- package/lib/replace.test.ts +46 -10
- package/lib/replace.ts +20 -3
- package/lib/types.ts +5 -0
- package/lib/utils/determineModuleType.test.ts +48 -0
- package/lib/utils/determineModuleType.ts +4 -6
- package/lib/utils/getSelectedProjects.ts +3 -3
- package/lib/utils/quit.ts +1 -1
- package/package.json +4 -3
- package/jest.config.js +0 -6
|
@@ -9,18 +9,16 @@ export type ModuleType = "commonjs" | "module";
|
|
|
9
9
|
* @returns "commonjs" or "module", defaulting to "module" if no `package.json` is found or if the found
|
|
10
10
|
* file does not include a `type` property.
|
|
11
11
|
*/
|
|
12
|
-
export function determineModuleType() {
|
|
13
|
-
const value = getRawTypeFromPackageJson();
|
|
12
|
+
export function determineModuleType(currentDir: string | null = process.cwd()) {
|
|
13
|
+
const value = getRawTypeFromPackageJson(currentDir);
|
|
14
14
|
return getTypeOrDefault(value);
|
|
15
15
|
}
|
|
16
16
|
|
|
17
|
-
function getRawTypeFromPackageJson() {
|
|
17
|
+
function getRawTypeFromPackageJson(currentDir: string | null) {
|
|
18
18
|
if (process.env.DITTO_MODULE_TYPE) {
|
|
19
19
|
return process.env.DITTO_MODULE_TYPE;
|
|
20
20
|
}
|
|
21
21
|
|
|
22
|
-
let currentDir: string | null = process.cwd(); // Get the current working directory
|
|
23
|
-
|
|
24
22
|
while (currentDir) {
|
|
25
23
|
const packageJsonPath = path.join(currentDir, "package.json");
|
|
26
24
|
if (fs.existsSync(packageJsonPath)) {
|
|
@@ -36,7 +34,7 @@ function getRawTypeFromPackageJson() {
|
|
|
36
34
|
}
|
|
37
35
|
|
|
38
36
|
if (currentDir === "/") {
|
|
39
|
-
|
|
37
|
+
break;
|
|
40
38
|
}
|
|
41
39
|
|
|
42
40
|
// Move up a directory and continue the search
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import fs from "fs";
|
|
2
2
|
import yaml, { YAMLException } from "js-yaml";
|
|
3
3
|
|
|
4
|
-
import
|
|
4
|
+
import consts from "../consts";
|
|
5
5
|
import { ConfigYAML, Project } from "../types";
|
|
6
6
|
import Config, { DEFAULT_CONFIG_JSON } from "../config";
|
|
7
7
|
|
|
@@ -29,8 +29,8 @@ function yamlToJson(_yaml: string): ConfigYAML | null {
|
|
|
29
29
|
* Returns an array containing all valid projects ({ id, name })
|
|
30
30
|
* currently contained in the project config file.
|
|
31
31
|
*/
|
|
32
|
-
export const getSelectedProjects = (configFile = PROJECT_CONFIG_FILE) =>
|
|
32
|
+
export const getSelectedProjects = (configFile = consts.PROJECT_CONFIG_FILE) =>
|
|
33
33
|
Config.parseSourceInformation(configFile).validProjects;
|
|
34
34
|
|
|
35
|
-
export const getIsUsingComponents = (configFile = PROJECT_CONFIG_FILE) =>
|
|
35
|
+
export const getIsUsingComponents = (configFile = consts.PROJECT_CONFIG_FILE) =>
|
|
36
36
|
Config.parseSourceInformation(configFile).shouldFetchComponentLibrary;
|
package/lib/utils/quit.ts
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@dittowords/cli",
|
|
3
|
-
"version": "4.
|
|
3
|
+
"version": "4.5.0",
|
|
4
4
|
"description": "Command Line Interface for Ditto (dittowords.com).",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"main": "bin/index.js",
|
|
@@ -35,6 +35,7 @@
|
|
|
35
35
|
"devDependencies": {
|
|
36
36
|
"@babel/preset-env": "^7.20.2",
|
|
37
37
|
"@babel/preset-typescript": "^7.18.6",
|
|
38
|
+
"@jest/globals": "^29.7.0",
|
|
38
39
|
"@sentry/cli": "^2.20.5",
|
|
39
40
|
"@tsconfig/node16": "^1.0.3",
|
|
40
41
|
"@types/jest": "^26.0.9",
|
|
@@ -51,6 +52,7 @@
|
|
|
51
52
|
"rewire": "^6.0.0",
|
|
52
53
|
"source-map": "^0.7.3",
|
|
53
54
|
"tempy": "^0.6.0",
|
|
55
|
+
"ts-node": "^10.9.2",
|
|
54
56
|
"typescript": "^4.7.4"
|
|
55
57
|
},
|
|
56
58
|
"dependencies": {
|
|
@@ -60,7 +62,6 @@
|
|
|
60
62
|
"@babel/types": "^7.21.4",
|
|
61
63
|
"@sentry/node": "^7.64.0",
|
|
62
64
|
"@types/babel-traverse": "^6.25.7",
|
|
63
|
-
"@types/fs-extra": "^11.0.1",
|
|
64
65
|
"axios": "^1.6.0",
|
|
65
66
|
"boxen": "^5.1.2",
|
|
66
67
|
"chalk": "^4.1.0",
|
|
@@ -68,9 +69,9 @@
|
|
|
68
69
|
"enquirer": "^2.3.6",
|
|
69
70
|
"faker": "^5.1.0",
|
|
70
71
|
"form-data": "^4.0.0",
|
|
71
|
-
"fs-extra": "^11.1.1",
|
|
72
72
|
"glob": "^9.3.4",
|
|
73
73
|
"js-yaml": "^4.1.0",
|
|
74
|
+
"memfs": "^4.7.7",
|
|
74
75
|
"ora": "^5.0.0",
|
|
75
76
|
"v8-compile-cache": "^2.1.1"
|
|
76
77
|
},
|