@formatjs/cli-lib 5.1.8 → 5.1.10
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/index.d.ts +8 -0
- package/index.d.ts.map +1 -0
- package/index.js +12 -0
- package/main.d.ts +2 -0
- package/main.d.ts.map +1 -0
- package/main.js +3 -0
- package/package.json +1 -1
- package/src/cli.d.ts +3 -0
- package/src/cli.d.ts.map +1 -0
- package/src/cli.js +165 -0
- package/src/compile.d.ts +48 -0
- package/src/compile.d.ts.map +1 -0
- package/src/compile.js +97 -0
- package/src/compile_folder.d.ts +3 -0
- package/src/compile_folder.d.ts.map +1 -0
- package/src/compile_folder.js +11 -0
- package/src/console_utils.d.ts +10 -0
- package/src/console_utils.d.ts.map +1 -0
- package/src/console_utils.js +76 -0
- package/src/extract.d.ts +75 -0
- package/src/extract.d.ts.map +1 -0
- package/src/extract.js +177 -0
- package/src/formatters/crowdin.d.ts +8 -0
- package/src/formatters/crowdin.d.ts.map +1 -0
- package/src/formatters/crowdin.js +27 -0
- package/src/formatters/default.d.ts +6 -0
- package/src/formatters/default.d.ts.map +1 -0
- package/src/formatters/default.js +13 -0
- package/src/formatters/index.d.ts +9 -0
- package/src/formatters/index.d.ts.map +1 -0
- package/src/formatters/index.js +42 -0
- package/src/formatters/lokalise.d.ts +10 -0
- package/src/formatters/lokalise.d.ts.map +1 -0
- package/src/formatters/lokalise.js +24 -0
- package/src/formatters/simple.d.ts +5 -0
- package/src/formatters/simple.d.ts.map +1 -0
- package/src/formatters/simple.js +12 -0
- package/src/formatters/smartling.d.ts +24 -0
- package/src/formatters/smartling.d.ts.map +1 -0
- package/src/formatters/smartling.js +50 -0
- package/src/formatters/transifex.d.ts +10 -0
- package/src/formatters/transifex.d.ts.map +1 -0
- package/src/formatters/transifex.js +24 -0
- package/src/parse_script.d.ts +8 -0
- package/src/parse_script.d.ts.map +1 -0
- package/src/parse_script.js +51 -0
- package/src/pseudo_locale.d.ts +7 -0
- package/src/pseudo_locale.d.ts.map +1 -0
- package/src/pseudo_locale.js +100 -0
- package/src/vue_extractor.d.ts +3 -0
- package/src/vue_extractor.d.ts.map +1 -0
- package/src/vue_extractor.js +62 -0
- package/BUILD +0 -118
- package/CHANGELOG.md +0 -1147
- package/index.ts +0 -7
- package/main.ts +0 -5
- package/src/cli.ts +0 -240
- package/src/compile.ts +0 -141
- package/src/compile_folder.ts +0 -15
- package/src/console_utils.ts +0 -78
- package/src/extract.ts +0 -273
- package/src/formatters/crowdin.ts +0 -34
- package/src/formatters/default.ts +0 -19
- package/src/formatters/index.ts +0 -46
- package/src/formatters/lokalise.ts +0 -33
- package/src/formatters/simple.ts +0 -12
- package/src/formatters/smartling.ts +0 -73
- package/src/formatters/transifex.ts +0 -33
- package/src/parse_script.ts +0 -49
- package/src/pseudo_locale.ts +0 -113
- package/src/vue_extractor.ts +0 -96
- package/tests/unit/__snapshots__/pseudo_locale.test.ts.snap +0 -24
- package/tests/unit/__snapshots__/unit.test.ts.snap +0 -42
- package/tests/unit/__snapshots__/vue_extractor.test.ts.snap +0 -36
- package/tests/unit/fixtures/bind.vue +0 -46
- package/tests/unit/fixtures/comp.vue +0 -17
- package/tests/unit/pseudo_locale.test.ts +0 -7
- package/tests/unit/unit.test.ts +0 -44
- package/tests/unit/vue_extractor.test.ts +0 -38
- package/tsconfig.json +0 -5
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"vue_extractor.d.ts","sourceRoot":"","sources":["vue_extractor.ts"],"names":[],"mappings":"AAWA,MAAM,MAAM,aAAa,GAAG,CAAC,MAAM,EAAE,MAAM,KAAK,IAAI,CAAA;AA4DpD,wBAAgB,SAAS,CACvB,MAAM,EAAE,MAAM,EACd,QAAQ,EAAE,MAAM,EAChB,aAAa,EAAE,aAAa,GAC3B,GAAG,CAoBL"}
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.parseFile = void 0;
|
|
4
|
+
const compiler_sfc_1 = require("@vue/compiler-sfc");
|
|
5
|
+
function walk(node, visitor) {
|
|
6
|
+
if (typeof node !== 'object') {
|
|
7
|
+
return;
|
|
8
|
+
}
|
|
9
|
+
if (node.type !== 1 /* NodeTypes.ELEMENT */ &&
|
|
10
|
+
node.type !== 8 /* NodeTypes.COMPOUND_EXPRESSION */ &&
|
|
11
|
+
node.type !== 5 /* NodeTypes.INTERPOLATION */) {
|
|
12
|
+
return;
|
|
13
|
+
}
|
|
14
|
+
visitor(node);
|
|
15
|
+
if (node.type === 5 /* NodeTypes.INTERPOLATION */) {
|
|
16
|
+
visitor(node.content);
|
|
17
|
+
}
|
|
18
|
+
else if (node.type === 1 /* NodeTypes.ELEMENT */) {
|
|
19
|
+
node.children.forEach(n => walk(n, visitor));
|
|
20
|
+
node.props
|
|
21
|
+
.filter((prop) => prop.type === 7 /* NodeTypes.DIRECTIVE */)
|
|
22
|
+
.filter(prop => !!prop.exp)
|
|
23
|
+
.forEach(prop => visitor(prop.exp));
|
|
24
|
+
}
|
|
25
|
+
else {
|
|
26
|
+
node.children.forEach(n => walk(n, visitor));
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
function templateSimpleExpressionNodeVisitor(parseScriptFn) {
|
|
30
|
+
return (n) => {
|
|
31
|
+
if (typeof n !== 'object') {
|
|
32
|
+
return;
|
|
33
|
+
}
|
|
34
|
+
if (n.type !== 4 /* NodeTypes.SIMPLE_EXPRESSION */) {
|
|
35
|
+
return;
|
|
36
|
+
}
|
|
37
|
+
const { content } = n;
|
|
38
|
+
// Wrap this in () since a vue comp node attribute can just be
|
|
39
|
+
// an object literal which, by itself is invalid TS
|
|
40
|
+
// but with () it becomes an ExpressionStatement
|
|
41
|
+
parseScriptFn(`(${content})`);
|
|
42
|
+
};
|
|
43
|
+
}
|
|
44
|
+
function parseFile(source, filename, parseScriptFn) {
|
|
45
|
+
const { descriptor, errors } = (0, compiler_sfc_1.parse)(source, {
|
|
46
|
+
filename,
|
|
47
|
+
});
|
|
48
|
+
if (errors.length) {
|
|
49
|
+
throw errors[0];
|
|
50
|
+
}
|
|
51
|
+
const { script, scriptSetup, template } = descriptor;
|
|
52
|
+
if (template) {
|
|
53
|
+
walk(template.ast, templateSimpleExpressionNodeVisitor(parseScriptFn));
|
|
54
|
+
}
|
|
55
|
+
if (script) {
|
|
56
|
+
parseScriptFn(script.content);
|
|
57
|
+
}
|
|
58
|
+
if (scriptSetup) {
|
|
59
|
+
parseScriptFn(scriptSetup.content);
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
exports.parseFile = parseFile;
|
package/BUILD
DELETED
|
@@ -1,118 +0,0 @@
|
|
|
1
|
-
load("@aspect_bazel_lib//lib:write_source_files.bzl", "write_source_files")
|
|
2
|
-
load("@aspect_rules_esbuild//esbuild:defs.bzl", "esbuild")
|
|
3
|
-
load("@aspect_rules_js//npm/private:npm_package.bzl", "npm_package")
|
|
4
|
-
load("@npm//:defs.bzl", "npm_link_all_packages")
|
|
5
|
-
load("//tools:index.bzl", "check_format", "package_json_test", "ts_compile_node")
|
|
6
|
-
load("//tools:jest.bzl", "jest_test")
|
|
7
|
-
|
|
8
|
-
npm_link_all_packages(name = "node_modules")
|
|
9
|
-
|
|
10
|
-
PACKAGE_NAME = "cli-lib"
|
|
11
|
-
|
|
12
|
-
exports_files(["package.json"])
|
|
13
|
-
|
|
14
|
-
npm_package(
|
|
15
|
-
name = PACKAGE_NAME,
|
|
16
|
-
srcs = [
|
|
17
|
-
"LICENSE.md",
|
|
18
|
-
"README.md",
|
|
19
|
-
"package.json",
|
|
20
|
-
":dist",
|
|
21
|
-
],
|
|
22
|
-
package = "@formatjs/%s" % PACKAGE_NAME,
|
|
23
|
-
visibility = ["//visibility:public"],
|
|
24
|
-
)
|
|
25
|
-
|
|
26
|
-
SRCS = glob(["src/**/*.ts"]) + [
|
|
27
|
-
"index.ts",
|
|
28
|
-
"main.ts",
|
|
29
|
-
# "package.json",
|
|
30
|
-
]
|
|
31
|
-
|
|
32
|
-
VUE_DEPS = [
|
|
33
|
-
"//:node_modules/@vue/compiler-core",
|
|
34
|
-
"//:node_modules/@babel/types",
|
|
35
|
-
"//:node_modules/@vue/compiler-sfc",
|
|
36
|
-
]
|
|
37
|
-
|
|
38
|
-
SRC_DEPS = [
|
|
39
|
-
"//:node_modules/@types/estree",
|
|
40
|
-
"//:node_modules/@types/fs-extra",
|
|
41
|
-
"//:node_modules/@types/json-stable-stringify",
|
|
42
|
-
"//:node_modules/@types/node",
|
|
43
|
-
"//:node_modules/chalk",
|
|
44
|
-
"//:node_modules/commander",
|
|
45
|
-
"//:node_modules/fast-glob",
|
|
46
|
-
"//:node_modules/fs-extra",
|
|
47
|
-
"//:node_modules/json-stable-stringify",
|
|
48
|
-
"//:node_modules/loud-rejection",
|
|
49
|
-
"//:node_modules/typescript",
|
|
50
|
-
":node_modules/@formatjs/icu-messageformat-parser",
|
|
51
|
-
":node_modules/@formatjs/ts-transformer",
|
|
52
|
-
] + VUE_DEPS
|
|
53
|
-
|
|
54
|
-
ts_compile_node(
|
|
55
|
-
name = "dist",
|
|
56
|
-
srcs = SRCS,
|
|
57
|
-
package = "@formatjs/%s" % PACKAGE_NAME,
|
|
58
|
-
skip_esm_esnext = False,
|
|
59
|
-
deps = SRC_DEPS,
|
|
60
|
-
)
|
|
61
|
-
|
|
62
|
-
jest_test(
|
|
63
|
-
name = "unit",
|
|
64
|
-
srcs = SRCS + glob([
|
|
65
|
-
"tests/unit/**/*",
|
|
66
|
-
]),
|
|
67
|
-
deps = [
|
|
68
|
-
"//:node_modules/rimraf",
|
|
69
|
-
"//:node_modules/@types/rimraf",
|
|
70
|
-
] + SRC_DEPS,
|
|
71
|
-
)
|
|
72
|
-
|
|
73
|
-
write_source_files(
|
|
74
|
-
name = "tsconfig_json",
|
|
75
|
-
files = {"tsconfig.json": "//tools:tsconfig.golden.json"},
|
|
76
|
-
)
|
|
77
|
-
|
|
78
|
-
check_format(
|
|
79
|
-
name = "prettier",
|
|
80
|
-
srcs = glob(
|
|
81
|
-
[
|
|
82
|
-
"**/*",
|
|
83
|
-
],
|
|
84
|
-
exclude = [
|
|
85
|
-
"CHANGELOG.md",
|
|
86
|
-
# Intentional err
|
|
87
|
-
"tests/integration/extract/typescript/err.tsx",
|
|
88
|
-
"tests/**/__snapshots__/*",
|
|
89
|
-
],
|
|
90
|
-
),
|
|
91
|
-
)
|
|
92
|
-
|
|
93
|
-
genrule(
|
|
94
|
-
name = "bin",
|
|
95
|
-
srcs = [":formatjs.js"],
|
|
96
|
-
outs = ["bin/formatjs"],
|
|
97
|
-
cmd = "cp $< $@",
|
|
98
|
-
)
|
|
99
|
-
|
|
100
|
-
esbuild(
|
|
101
|
-
name = "formatjs",
|
|
102
|
-
srcs = [":dist-esm-esnext"],
|
|
103
|
-
entry_point = "lib_esnext/main.js",
|
|
104
|
-
external = [
|
|
105
|
-
"@vue/compiler-sfc",
|
|
106
|
-
],
|
|
107
|
-
platform = "node",
|
|
108
|
-
target = "node16",
|
|
109
|
-
visibility = ["//packages/cli:__pkg__"],
|
|
110
|
-
deps = [
|
|
111
|
-
"//:node_modules/tslib",
|
|
112
|
-
] + SRC_DEPS,
|
|
113
|
-
)
|
|
114
|
-
|
|
115
|
-
package_json_test(
|
|
116
|
-
name = "package_json_test",
|
|
117
|
-
deps = SRC_DEPS,
|
|
118
|
-
)
|