@wp-blocks/make-pot 0.1.0 → 1.0.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/CODE_OF_CONDUCT.md +45 -0
- package/CONTRIBUTING.md +92 -0
- package/README.md +54 -3
- package/lib/assets/block-i18n.json +17 -0
- package/lib/assets/package-i18n.json +11 -0
- package/lib/assets/theme-i18n.json +86 -0
- package/lib/assets/wp-plugin-i18n.json +14 -0
- package/lib/assets/wp-theme-i18n.json +13 -0
- package/lib/cli/index.d.ts +1 -0
- package/lib/cli/index.js +114 -0
- package/lib/cli/index.js.map +1 -0
- package/lib/cli/parseCli.d.ts +3 -0
- package/lib/cli/parseCli.js +111 -0
- package/lib/cli/parseCli.js.map +1 -0
- package/lib/cliArgs.js +41 -8
- package/lib/cliArgs.js.map +1 -1
- package/lib/const.d.ts +112 -0
- package/lib/const.js +42 -5
- package/lib/const.js.map +1 -1
- package/lib/extractors/css.d.ts +2 -0
- package/lib/extractors/css.js +42 -0
- package/lib/extractors/css.js.map +1 -0
- package/lib/extractors/headers.d.ts +6 -0
- package/lib/extractors/headers.js +59 -0
- package/lib/extractors/headers.js.map +1 -0
- package/lib/extractors/index.d.ts +2 -0
- package/lib/extractors/index.js +60 -0
- package/lib/extractors/index.js.map +1 -0
- package/lib/extractors/json.d.ts +9 -0
- package/lib/extractors/json.js +82 -0
- package/lib/extractors/json.js.map +1 -0
- package/lib/extractors/php.d.ts +3 -0
- package/lib/extractors/php.js +49 -0
- package/lib/extractors/php.js.map +1 -0
- package/lib/extractors/schema.d.ts +13 -0
- package/lib/extractors/schema.js +121 -0
- package/lib/extractors/schema.js.map +1 -0
- package/lib/extractors/text.d.ts +1 -0
- package/lib/{extractors-text.js → extractors/text.js} +7 -10
- package/lib/extractors/text.js.map +1 -0
- package/lib/extractors/utils.d.ts +5 -0
- package/lib/extractors/utils.js +54 -0
- package/lib/extractors/utils.js.map +1 -0
- package/lib/fs/glob.d.ts +13 -0
- package/lib/fs/glob.js +95 -0
- package/lib/fs/glob.js.map +1 -0
- package/lib/fs/index.d.ts +2 -0
- package/lib/fs/index.js +69 -0
- package/lib/fs/index.js.map +1 -0
- package/lib/fs.d.ts +2 -1
- package/lib/fs.js +15 -8
- package/lib/fs.js.map +1 -1
- package/lib/index.js +5 -3
- package/lib/index.js.map +1 -1
- package/lib/makePot.d.ts +1 -1
- package/lib/makePot.js +38 -27
- package/lib/makePot.js.map +1 -1
- package/lib/maps.d.ts +122 -0
- package/lib/maps.js +73 -0
- package/lib/maps.js.map +1 -0
- package/lib/parser/consolidate.d.ts +2 -0
- package/lib/parser/consolidate.js +37 -0
- package/lib/parser/consolidate.js.map +1 -0
- package/lib/parser/exec.d.ts +3 -0
- package/lib/parser/exec.js +71 -0
- package/lib/parser/exec.js.map +1 -0
- package/lib/parser/index.d.ts +2 -0
- package/lib/parser/index.js +24 -0
- package/lib/parser/index.js.map +1 -0
- package/lib/parser/makePot.d.ts +2 -0
- package/lib/parser/makePot.js +39 -0
- package/lib/parser/makePot.js.map +1 -0
- package/lib/parser/patterns.d.ts +2 -0
- package/lib/parser/patterns.js +34 -0
- package/lib/parser/patterns.js.map +1 -0
- package/lib/parser/process.d.ts +5 -0
- package/lib/parser/process.js +71 -0
- package/lib/parser/process.js.map +1 -0
- package/lib/parser/tree.d.ts +2 -0
- package/lib/parser/tree.js +78 -0
- package/lib/parser/tree.js.map +1 -0
- package/lib/parser.d.ts +2 -2
- package/lib/parser.js +58 -57
- package/lib/parser.js.map +1 -1
- package/lib/tree.js +6 -6
- package/lib/tree.js.map +1 -1
- package/lib/types.d.ts +7 -4
- package/lib/utils/index.d.ts +8 -0
- package/lib/utils/index.js +78 -0
- package/lib/utils/index.js.map +1 -0
- package/lib/utils.d.ts +3 -3
- package/lib/utils.js +16 -13
- package/lib/utils.js.map +1 -1
- package/package.json +19 -10
- package/tests/consolidate.test.ts +1 -1
- package/tests/{extract-2.old.ts → extract-2.test.ts} +10 -3
- package/tests/getFiles.old.ts +1 -1
- package/tests/getStrings.old.ts +1 -1
- package/tests/{jsonParse.test.ts → jsonParse.ts} +9 -8
- package/lib/extractors-json.d.ts +0 -9
- package/lib/extractors-json.js +0 -53
- package/lib/extractors-json.js.map +0 -1
- package/lib/extractors-maps.d.ts +0 -109
- package/lib/extractors-maps.js +0 -139
- package/lib/extractors-maps.js.map +0 -1
- package/lib/extractors-php.d.ts +0 -1
- package/lib/extractors-php.js +0 -25
- package/lib/extractors-php.js.map +0 -1
- package/lib/extractors-text.d.ts +0 -1
- package/lib/extractors-text.js.map +0 -1
- package/lib/extractors.d.ts +0 -17
- package/lib/extractors.js +0 -137
- package/lib/extractors.js.map +0 -1
- package/tests/index.html +0 -78
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
# Contributor Covenant Code of Conduct
|
|
2
|
+
|
|
3
|
+
## Our Pledge
|
|
4
|
+
|
|
5
|
+
In the interest of fostering an open and welcoming environment, we as contributors and maintainers pledge to make participation in our project and our community a harassment-free experience for everyone, regardless of age, body size, disability, ethnicity, sex characteristics, gender identity and expression, level of experience, education, socio-economic status, nationality, personal appearance, race, religion, or sexual identity and orientation.
|
|
6
|
+
|
|
7
|
+
## Our Standards
|
|
8
|
+
|
|
9
|
+
Examples of behavior that contributes to creating a positive environment include:
|
|
10
|
+
|
|
11
|
+
* Using welcoming and inclusive language
|
|
12
|
+
* Being respectful of differing viewpoints and experiences
|
|
13
|
+
* Gracefully accepting constructive criticism
|
|
14
|
+
* Focusing on what is best for the community
|
|
15
|
+
* Showing empathy towards other community members
|
|
16
|
+
|
|
17
|
+
Examples of unacceptable behavior by participants include:
|
|
18
|
+
|
|
19
|
+
* The use of sexualized language or imagery and unwelcome sexual attention or advances
|
|
20
|
+
* Trolling, insulting/derogatory comments, and personal or political attacks
|
|
21
|
+
* Public or private harassment
|
|
22
|
+
* Publishing others' private information, such as a physical or electronic address, without explicit permission
|
|
23
|
+
* Other conduct which could reasonably be considered inappropriate in a professional setting
|
|
24
|
+
|
|
25
|
+
## Our Responsibilities
|
|
26
|
+
|
|
27
|
+
Project maintainers are responsible for clarifying the standards of acceptable behavior and are expected to take appropriate and fair corrective action in response to any instances of unacceptable behavior.
|
|
28
|
+
|
|
29
|
+
Project maintainers have the right and responsibility to remove, edit, or reject comments, commits, code, wiki edits, issues, and other contributions that are not aligned to this Code of Conduct, or to ban temporarily or permanently any contributor for other behaviors that they deem inappropriate, threatening, offensive, or harmful.
|
|
30
|
+
|
|
31
|
+
## Scope
|
|
32
|
+
|
|
33
|
+
This Code of Conduct applies within all project spaces, and it also applies when an individual is representing the project or its community in public spaces. Examples of representing a project or community include using an official project e-mail address, posting via an official social media account, or acting as an appointed representative at an online or offline event. Representation of a project may be further defined and clarified by project maintainers.
|
|
34
|
+
|
|
35
|
+
## Enforcement
|
|
36
|
+
|
|
37
|
+
Instances of abusive, harassing, or otherwise unacceptable behavior may be reported by contacting the project maintainer using any of the [private contact addresses](https://github.com/dec0dOS/amazing-github-template#support). All complaints will be reviewed and investigated and will result in a response that is deemed necessary and appropriate to the circumstances. The project team is obligated to maintain confidentiality with regard to the reporter of an incident. Further details of specific enforcement policies may be posted separately.
|
|
38
|
+
|
|
39
|
+
Project maintainers who do not follow or enforce the Code of Conduct in good faith may face temporary or permanent repercussions as determined by other members of the project's leadership.
|
|
40
|
+
|
|
41
|
+
## Attribution
|
|
42
|
+
|
|
43
|
+
This Code of Conduct is adapted from the [Contributor Covenant](https://www.contributor-covenant.org), version 1.4, available at <https://www.contributor-covenant.org/version/1/4/code-of-conduct.html>
|
|
44
|
+
|
|
45
|
+
For answers to common questions about this code of conduct, see <https://www.contributor-covenant.org/faq>
|
package/CONTRIBUTING.md
ADDED
|
@@ -0,0 +1,92 @@
|
|
|
1
|
+
# Contributing
|
|
2
|
+
|
|
3
|
+
When contributing to this repository, please first discuss the change you wish to make via issue,
|
|
4
|
+
email, or any other method with the owners of this repository before making a change.
|
|
5
|
+
|
|
6
|
+
Please note we have a code of conduct, please follow it in all your interactions with the project.
|
|
7
|
+
|
|
8
|
+
## Pull Request Process
|
|
9
|
+
|
|
10
|
+
1. Ensure any install or build dependencies are removed before the end of the layer when doing a
|
|
11
|
+
build.
|
|
12
|
+
2. Update the README.md with details of changes to the interface, this includes new environment
|
|
13
|
+
variables, exposed ports, useful file locations and container parameters.
|
|
14
|
+
3. Increase the version numbers in any examples files and the README.md to the new version that this
|
|
15
|
+
Pull Request would represent. The versioning scheme we use is [SemVer](http://semver.org/).
|
|
16
|
+
4. You may merge the Pull Request in once you have the sign-off of two other developers, or if you
|
|
17
|
+
do not have permission to do that, you may request the second reviewer to merge it for you.
|
|
18
|
+
|
|
19
|
+
## Code of Conduct
|
|
20
|
+
|
|
21
|
+
### Our Pledge
|
|
22
|
+
|
|
23
|
+
In the interest of fostering an open and welcoming environment, we as
|
|
24
|
+
contributors and maintainers pledge to making participation in our project and
|
|
25
|
+
our community a harassment-free experience for everyone, regardless of age, body
|
|
26
|
+
size, disability, ethnicity, gender identity and expression, level of experience,
|
|
27
|
+
nationality, personal appearance, race, religion, or sexual identity and
|
|
28
|
+
orientation.
|
|
29
|
+
|
|
30
|
+
### Our Standards
|
|
31
|
+
|
|
32
|
+
Examples of behavior that contributes to creating a positive environment
|
|
33
|
+
include:
|
|
34
|
+
|
|
35
|
+
* Using welcoming and inclusive language
|
|
36
|
+
* Being respectful of differing viewpoints and experiences
|
|
37
|
+
* Gracefully accepting constructive criticism
|
|
38
|
+
* Focusing on what is best for the community
|
|
39
|
+
* Showing empathy towards other community members
|
|
40
|
+
|
|
41
|
+
Examples of unacceptable behavior by participants include:
|
|
42
|
+
|
|
43
|
+
* The use of sexualized language or imagery and unwelcome sexual attention or
|
|
44
|
+
advances
|
|
45
|
+
* Trolling, insulting/derogatory comments, and personal or political attacks
|
|
46
|
+
* Public or private harassment
|
|
47
|
+
* Publishing others' private information, such as a physical or electronic
|
|
48
|
+
address, without explicit permission
|
|
49
|
+
* Other conduct which could reasonably be considered inappropriate in a
|
|
50
|
+
professional setting
|
|
51
|
+
|
|
52
|
+
### Our Responsibilities
|
|
53
|
+
|
|
54
|
+
Project maintainers are responsible for clarifying the standards of acceptable
|
|
55
|
+
behavior and are expected to take appropriate and fair corrective action in
|
|
56
|
+
response to any instances of unacceptable behavior.
|
|
57
|
+
|
|
58
|
+
Project maintainers have the right and responsibility to remove, edit, or
|
|
59
|
+
reject comments, commits, code, wiki edits, issues, and other contributions
|
|
60
|
+
that are not aligned to this Code of Conduct, or to ban temporarily or
|
|
61
|
+
permanently any contributor for other behaviors that they deem inappropriate,
|
|
62
|
+
threatening, offensive, or harmful.
|
|
63
|
+
|
|
64
|
+
### Scope
|
|
65
|
+
|
|
66
|
+
This Code of Conduct applies both within project spaces and in public spaces
|
|
67
|
+
when an individual is representing the project or its community. Examples of
|
|
68
|
+
representing a project or community include using an official project e-mail
|
|
69
|
+
address, posting via an official social media account, or acting as an appointed
|
|
70
|
+
representative at an online or offline event. Representation of a project may be
|
|
71
|
+
further defined and clarified by project maintainers.
|
|
72
|
+
|
|
73
|
+
### Enforcement
|
|
74
|
+
|
|
75
|
+
Instances of abusive, harassing, or otherwise unacceptable behavior may be
|
|
76
|
+
reported by contacting the project team. All
|
|
77
|
+
complaints will be reviewed and investigated and will result in a response that
|
|
78
|
+
is deemed necessary and appropriate to the circumstances. The project team is
|
|
79
|
+
obligated to maintain confidentiality with regard to the reporter of an incident.
|
|
80
|
+
Further details of specific enforcement policies may be posted separately.
|
|
81
|
+
|
|
82
|
+
Project maintainers who do not follow or enforce the Code of Conduct in good
|
|
83
|
+
faith may face temporary or permanent repercussions as determined by other
|
|
84
|
+
members of the project's leadership.
|
|
85
|
+
|
|
86
|
+
### Attribution
|
|
87
|
+
|
|
88
|
+
This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 1.4,
|
|
89
|
+
available at [http://contributor-covenant.org/version/1/4][version]
|
|
90
|
+
|
|
91
|
+
[homepage]: http://contributor-covenant.org
|
|
92
|
+
[version]: http://contributor-covenant.org/version/1/4/
|
package/README.md
CHANGED
|
@@ -1,7 +1,58 @@
|
|
|
1
|
-
|
|
1
|
+
## make-pot
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
`make-pot` is a Node.js module designed to generate the `.pot` file for your WordPress plugin or theme. This file serves as the basis for internationalization, allowing translators to localize your plugin or theme into different languages.
|
|
4
|
+
|
|
5
|
+
Extract strings from your WordPress plugin or theme and generate a `.pot` file. Works with `js`, `jx`, `ts`, `tsx`, `cjs`, `mjs`, `php`, `blade`, `txt`, `json` with a custom schema for theme and block.json files.
|
|
6
|
+
|
|
7
|
+
### Installation
|
|
8
|
+
|
|
9
|
+
You can install `make-pot` globally via npm:
|
|
4
10
|
|
|
5
11
|
```
|
|
6
|
-
|
|
12
|
+
npm install -g @wp-blocks/make-pot
|
|
7
13
|
```
|
|
14
|
+
|
|
15
|
+
### Usage
|
|
16
|
+
|
|
17
|
+
```bash
|
|
18
|
+
npx @wp-blocks/make-pot <sourceDirectory> [destination] [options]
|
|
19
|
+
```
|
|
20
|
+
|
|
21
|
+
#### Positional Arguments:
|
|
22
|
+
|
|
23
|
+
- `sourceDirectory`: Specifies the source directory of your plugin or theme.
|
|
24
|
+
- `destination` (optional): Specifies the destination directory where the `.pot` file will be generated. If not provided, the `.pot` file will be created in the source directory.
|
|
25
|
+
|
|
26
|
+
#### Options:
|
|
27
|
+
|
|
28
|
+
- `--version`: Displays the version number of `make-pot`.
|
|
29
|
+
- `-h`, `--help`: Displays help information.
|
|
30
|
+
- `--slug <slug>`: Specifies the plugin or theme slug.
|
|
31
|
+
- `--domain <domain>`: Specifies the text domain to look for in the source code.
|
|
32
|
+
- `--skip-js`: Skips JavaScript files during processing.
|
|
33
|
+
- `--skip-php`: Skips PHP files during processing.
|
|
34
|
+
- `--skip-blade`: Skips Blade files during processing.
|
|
35
|
+
- `--skip-block-json`: Skips block.json files during processing.
|
|
36
|
+
- `--skip-theme-json`: Skips theme.json files during processing.
|
|
37
|
+
- `--skip-audit`: Skips auditing of strings.
|
|
38
|
+
- `--headers <headers>`: Specifies additional headers for the `.pot` file.
|
|
39
|
+
- `--file-comment <comment>`: Specifies the file comment for the `.pot` file.
|
|
40
|
+
- `--package-name <name>`: Specifies the package name.
|
|
41
|
+
- `--location`: Includes location information in the `.pot` file.
|
|
42
|
+
- `--ignore-domain`: Ignores text domain in the processing.
|
|
43
|
+
- `--mergePaths <paths>`: Merges with existing POT file(s).
|
|
44
|
+
- `--subtractPaths <paths>`: Subtracts strings from existing POT file(s).
|
|
45
|
+
- `--subtractAndMerge`: Subtracts and merges strings from existing POT file(s).
|
|
46
|
+
- `--include <files>`: Includes specific files for processing.
|
|
47
|
+
- `--exclude <files>`: Excludes specific files from processing.
|
|
48
|
+
- `--silent`: Suppresses output to stdout.
|
|
49
|
+
- `--json`: Outputs the JSON gettext data.
|
|
50
|
+
- `--output`: Outputs the gettext data.
|
|
51
|
+
|
|
52
|
+
### Credits
|
|
53
|
+
|
|
54
|
+
This module is heavily inspired by the original `makepot` command from [WP-CLI](https://github.com/wp-cli/i18n-command).
|
|
55
|
+
Special thanks to the maintainers in particular [Swissspidy](https://github.com/swissspidy) which
|
|
56
|
+
has been very helpful with suggestions and tips on how to rebuild `make-pot`.
|
|
57
|
+
|
|
58
|
+
Feel free to contribute or report issues on [GitHub](https://github.com/example/example).
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
{
|
|
2
|
+
"title": "block title",
|
|
3
|
+
"description": "block description",
|
|
4
|
+
"keywords": ["block keyword"],
|
|
5
|
+
"styles": [
|
|
6
|
+
{
|
|
7
|
+
"label": "block style label"
|
|
8
|
+
}
|
|
9
|
+
],
|
|
10
|
+
"variations": [
|
|
11
|
+
{
|
|
12
|
+
"title": "block variation title",
|
|
13
|
+
"description": "block variation description",
|
|
14
|
+
"keywords": ["block variation keyword"]
|
|
15
|
+
}
|
|
16
|
+
]
|
|
17
|
+
}
|
|
@@ -0,0 +1,86 @@
|
|
|
1
|
+
{
|
|
2
|
+
"title": "Style variation name",
|
|
3
|
+
"settings": {
|
|
4
|
+
"typography": {
|
|
5
|
+
"fontSizes": [
|
|
6
|
+
{
|
|
7
|
+
"name": "Font size name"
|
|
8
|
+
}
|
|
9
|
+
],
|
|
10
|
+
"fontFamilies": [
|
|
11
|
+
{
|
|
12
|
+
"name": "Font family name"
|
|
13
|
+
}
|
|
14
|
+
]
|
|
15
|
+
},
|
|
16
|
+
"color": {
|
|
17
|
+
"palette": [
|
|
18
|
+
{
|
|
19
|
+
"name": "Color name"
|
|
20
|
+
}
|
|
21
|
+
],
|
|
22
|
+
"gradients": [
|
|
23
|
+
{
|
|
24
|
+
"name": "Gradient name"
|
|
25
|
+
}
|
|
26
|
+
],
|
|
27
|
+
"duotone": [
|
|
28
|
+
{
|
|
29
|
+
"name": "Duotone name"
|
|
30
|
+
}
|
|
31
|
+
]
|
|
32
|
+
},
|
|
33
|
+
"spacing": {
|
|
34
|
+
"spacingSizes": [
|
|
35
|
+
{
|
|
36
|
+
"name": "Space size name"
|
|
37
|
+
}
|
|
38
|
+
]
|
|
39
|
+
},
|
|
40
|
+
"blocks": {
|
|
41
|
+
"*": {
|
|
42
|
+
"typography": {
|
|
43
|
+
"fontSizes": [
|
|
44
|
+
{
|
|
45
|
+
"name": "Font size name"
|
|
46
|
+
}
|
|
47
|
+
],
|
|
48
|
+
"fontFamilies": [
|
|
49
|
+
{
|
|
50
|
+
"name": "Font family name"
|
|
51
|
+
}
|
|
52
|
+
]
|
|
53
|
+
},
|
|
54
|
+
"color": {
|
|
55
|
+
"palette": [
|
|
56
|
+
{
|
|
57
|
+
"name": "Color name"
|
|
58
|
+
}
|
|
59
|
+
],
|
|
60
|
+
"gradients": [
|
|
61
|
+
{
|
|
62
|
+
"name": "Gradient name"
|
|
63
|
+
}
|
|
64
|
+
]
|
|
65
|
+
},
|
|
66
|
+
"spacing": {
|
|
67
|
+
"spacingSizes": [
|
|
68
|
+
{
|
|
69
|
+
"name": "Space size name"
|
|
70
|
+
}
|
|
71
|
+
]
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
},
|
|
76
|
+
"customTemplates": [
|
|
77
|
+
{
|
|
78
|
+
"title": "Custom template name"
|
|
79
|
+
}
|
|
80
|
+
],
|
|
81
|
+
"templateParts": [
|
|
82
|
+
{
|
|
83
|
+
"title": "Template part name"
|
|
84
|
+
}
|
|
85
|
+
]
|
|
86
|
+
}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "Plugin Name",
|
|
3
|
+
"url": "Plugin URI",
|
|
4
|
+
"description": "Description",
|
|
5
|
+
"version": "Version",
|
|
6
|
+
"author": "Author",
|
|
7
|
+
"authorUri": "Author URI",
|
|
8
|
+
"tags": "Tags",
|
|
9
|
+
"license": "License",
|
|
10
|
+
"licenseUri": "License URI",
|
|
11
|
+
"updateUri": "Update URI",
|
|
12
|
+
"domainPath": "Domain Path",
|
|
13
|
+
"textDomain": "Text Domain"
|
|
14
|
+
}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "Theme Name",
|
|
3
|
+
"author": "Author",
|
|
4
|
+
"authorUri": "Author URI",
|
|
5
|
+
"description": "Description",
|
|
6
|
+
"url": "Theme URI",
|
|
7
|
+
"tags": "Tags",
|
|
8
|
+
"version": "Version",
|
|
9
|
+
"license": "License",
|
|
10
|
+
"licenseUri": "License URI",
|
|
11
|
+
"domainPath": "Domain Path",
|
|
12
|
+
"textDomain": "Text Domain"
|
|
13
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function getArgs(): import("../types").Args;
|
package/lib/cli/index.js
ADDED
|
@@ -0,0 +1,114 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.getArgs = void 0;
|
|
7
|
+
const yargs_1 = __importDefault(require("yargs"));
|
|
8
|
+
const helpers_1 = require("yargs/helpers");
|
|
9
|
+
const process_1 = __importDefault(require("process"));
|
|
10
|
+
const parseCli_1 = require("./parseCli");
|
|
11
|
+
function getArgs() {
|
|
12
|
+
const args = (0, yargs_1.default)((0, helpers_1.hideBin)(process_1.default.argv))
|
|
13
|
+
.help('h')
|
|
14
|
+
.alias('help', 'help')
|
|
15
|
+
.usage('Usage: $0 <source> [destination] [options]')
|
|
16
|
+
.positional('sourceDirectory', {
|
|
17
|
+
describe: 'Source directory',
|
|
18
|
+
type: 'string',
|
|
19
|
+
})
|
|
20
|
+
.positional('destination', {
|
|
21
|
+
describe: 'Destination directory',
|
|
22
|
+
type: 'string',
|
|
23
|
+
})
|
|
24
|
+
.options({
|
|
25
|
+
slug: {
|
|
26
|
+
describe: 'Plugin or theme slug',
|
|
27
|
+
type: 'string',
|
|
28
|
+
},
|
|
29
|
+
domain: {
|
|
30
|
+
describe: 'Text domain to look for in the source code',
|
|
31
|
+
type: 'string',
|
|
32
|
+
},
|
|
33
|
+
'skip-js': {
|
|
34
|
+
describe: 'Skip JavaScript files',
|
|
35
|
+
type: 'boolean',
|
|
36
|
+
},
|
|
37
|
+
'skip-php': {
|
|
38
|
+
describe: 'Skip PHP files',
|
|
39
|
+
type: 'boolean',
|
|
40
|
+
},
|
|
41
|
+
'skip-blade': {
|
|
42
|
+
describe: 'Skip Blade files',
|
|
43
|
+
type: 'boolean',
|
|
44
|
+
},
|
|
45
|
+
'skip-block-json': {
|
|
46
|
+
describe: 'Skip block.json files',
|
|
47
|
+
type: 'boolean',
|
|
48
|
+
},
|
|
49
|
+
'skip-theme-json': {
|
|
50
|
+
describe: 'Skip theme.json files',
|
|
51
|
+
type: 'boolean',
|
|
52
|
+
},
|
|
53
|
+
'skip-audit': {
|
|
54
|
+
describe: 'Skip auditing of strings',
|
|
55
|
+
type: 'boolean',
|
|
56
|
+
},
|
|
57
|
+
headers: {
|
|
58
|
+
describe: 'Headers',
|
|
59
|
+
type: 'string',
|
|
60
|
+
},
|
|
61
|
+
'file-comment': {
|
|
62
|
+
describe: 'File comment',
|
|
63
|
+
type: 'string',
|
|
64
|
+
},
|
|
65
|
+
'package-name': {
|
|
66
|
+
describe: 'Package name',
|
|
67
|
+
type: 'string',
|
|
68
|
+
},
|
|
69
|
+
location: {
|
|
70
|
+
describe: 'Include location information',
|
|
71
|
+
type: 'boolean',
|
|
72
|
+
},
|
|
73
|
+
'ignore-domain': {
|
|
74
|
+
describe: 'Ignore text domain',
|
|
75
|
+
type: 'boolean',
|
|
76
|
+
},
|
|
77
|
+
mergePaths: {
|
|
78
|
+
describe: 'Merge with existing POT file(s)',
|
|
79
|
+
type: 'string',
|
|
80
|
+
},
|
|
81
|
+
subtractPaths: {
|
|
82
|
+
describe: 'Subtract strings from existing POT file(s)',
|
|
83
|
+
type: 'string',
|
|
84
|
+
},
|
|
85
|
+
subtractAndMerge: {
|
|
86
|
+
describe: 'Subtract and merge strings from existing POT file(s)',
|
|
87
|
+
type: 'boolean',
|
|
88
|
+
},
|
|
89
|
+
include: {
|
|
90
|
+
describe: 'Include specific files',
|
|
91
|
+
type: 'string',
|
|
92
|
+
},
|
|
93
|
+
exclude: {
|
|
94
|
+
describe: 'Exclude specific files',
|
|
95
|
+
type: 'string',
|
|
96
|
+
},
|
|
97
|
+
silent: {
|
|
98
|
+
describe: 'No output to stdout',
|
|
99
|
+
type: 'boolean',
|
|
100
|
+
},
|
|
101
|
+
json: {
|
|
102
|
+
describe: 'Output the json gettext data',
|
|
103
|
+
type: 'boolean',
|
|
104
|
+
},
|
|
105
|
+
output: {
|
|
106
|
+
describe: 'Output the gettext data',
|
|
107
|
+
type: 'boolean',
|
|
108
|
+
},
|
|
109
|
+
})
|
|
110
|
+
.parseSync();
|
|
111
|
+
return (0, parseCli_1.parseCliArgs)(args);
|
|
112
|
+
}
|
|
113
|
+
exports.getArgs = getArgs;
|
|
114
|
+
//# sourceMappingURL=index.js.map
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AAE,QAAQ;SACd;QACD,cAAc,EAAE;YACf,QAAQ,EAAE,cAAc;YACxB,IAAI,EAAE,QAAQ;SACd;QACD,cAAc,EAAE;YACf,QAAQ,EAAE,cAAc;YACxB,IAAI,EAAE,QAAQ;SACd;QACD,QAAQ,EAAE;YACT,QAAQ,EAAE,8BAA8B;YACxC,IAAI,EAAE,SAAS;SACf;QACD,eAAe,EAAE;YAChB,QAAQ,EAAE,oBAAoB;YAC9B,IAAI,EAAE,SAAS;SACf;QACD,UAAU,EAAE;YACX,QAAQ,EAAE,iCAAiC;YAC3C,IAAI,EAAE,QAAQ;SACd;QACD,aAAa,EAAE;YACd,QAAQ,EAAE,4CAA4C;YACtD,IAAI,EAAE,QAAQ;SACd;QACD,gBAAgB,EAAE;YACjB,QAAQ,EACP,sDAAsD;YACvD,IAAI,EAAE,SAAS;SACf;QACD,OAAO,EAAE;YACR,QAAQ,EAAE,wBAAwB;YAClC,IAAI,EAAE,QAAQ;SACd;QACD,OAAO,EAAE;YACR,QAAQ,EAAE,wBAAwB;YAClC,IAAI,EAAE,QAAQ;SACd;QACD,MAAM,EAAE;YACP,QAAQ,EAAE,qBAAqB;YAC/B,IAAI,EAAE,SAAS;SACf;QACD,IAAI,EAAE;YACL,QAAQ,EAAE,8BAA8B;YACxC,IAAI,EAAE,SAAS;SACf;QACD,MAAM,EAAE;YACP,QAAQ,EAAE,yBAAyB;YACnC,IAAI,EAAE,SAAS;SACf;KACD,CAAC;SACD,SAAS,EAAE,CAAA;IACb,OAAO,IAAA,uBAAY,EAAC,IAAI,CAAC,CAAA;AAC1B,CAAC;AAtGD,0BAsGC"}
|
|
@@ -0,0 +1,111 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
+
}) : function(o, v) {
|
|
16
|
+
o["default"] = v;
|
|
17
|
+
});
|
|
18
|
+
var __importStar = (this && this.__importStar) || function (mod) {
|
|
19
|
+
if (mod && mod.__esModule) return mod;
|
|
20
|
+
var result = {};
|
|
21
|
+
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
22
|
+
__setModuleDefault(result, mod);
|
|
23
|
+
return result;
|
|
24
|
+
};
|
|
25
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
26
|
+
exports.parseCliArgs = void 0;
|
|
27
|
+
const utils_1 = require("../utils");
|
|
28
|
+
const path = __importStar(require("path"));
|
|
29
|
+
const process = __importStar(require("process"));
|
|
30
|
+
const const_1 = require("../const");
|
|
31
|
+
const node_fs_1 = __importStar(require("node:fs"));
|
|
32
|
+
function isThemeOrPlugin(currentPath = '/', slug) {
|
|
33
|
+
const currentWorkingDirectory = currentPath;
|
|
34
|
+
try {
|
|
35
|
+
(0, node_fs_1.accessSync)(path.join(currentWorkingDirectory, slug + '.php'), node_fs_1.default.constants.R_OK);
|
|
36
|
+
return 'plugin';
|
|
37
|
+
}
|
|
38
|
+
catch (err) {
|
|
39
|
+
console.log('the current working directory ' +
|
|
40
|
+
currentWorkingDirectory +
|
|
41
|
+
' does not contain a ' +
|
|
42
|
+
slug +
|
|
43
|
+
'.php file');
|
|
44
|
+
}
|
|
45
|
+
try {
|
|
46
|
+
(0, node_fs_1.accessSync)(path.join(currentWorkingDirectory, 'style.css'), node_fs_1.default.constants.R_OK);
|
|
47
|
+
return 'theme';
|
|
48
|
+
}
|
|
49
|
+
catch (err) {
|
|
50
|
+
console.log('the current working directory ' +
|
|
51
|
+
currentWorkingDirectory +
|
|
52
|
+
' does not contain a style.css file');
|
|
53
|
+
}
|
|
54
|
+
if (currentWorkingDirectory.includes('themes')) {
|
|
55
|
+
return 'theme';
|
|
56
|
+
}
|
|
57
|
+
else if (currentWorkingDirectory.includes('plugins')) {
|
|
58
|
+
return 'plugin';
|
|
59
|
+
}
|
|
60
|
+
return 'generic';
|
|
61
|
+
}
|
|
62
|
+
function parseCliArgs(args) {
|
|
63
|
+
var _a, _b, _c, _d, _e, _f;
|
|
64
|
+
const inputPath = typeof args._[0] === 'string' ? args._[0] : '.';
|
|
65
|
+
const outputPath = typeof args._[1] === 'string' ? args._[1] : '.';
|
|
66
|
+
const currentWorkingDirectory = process.cwd();
|
|
67
|
+
const slug = args.slug && typeof args.slug === 'string'
|
|
68
|
+
? args.slug
|
|
69
|
+
: path.basename(path.resolve(currentWorkingDirectory, inputPath));
|
|
70
|
+
const cwd = path.relative(currentWorkingDirectory, inputPath);
|
|
71
|
+
const out = path.relative(currentWorkingDirectory, outputPath);
|
|
72
|
+
const domain = (_a = args === null || args === void 0 ? void 0 : args.domain) !== null && _a !== void 0 ? _a : isThemeOrPlugin(path.resolve(cwd), slug);
|
|
73
|
+
const parsedArgs = {
|
|
74
|
+
slug: slug,
|
|
75
|
+
domain: domain,
|
|
76
|
+
paths: { cwd: cwd, out: out },
|
|
77
|
+
options: {
|
|
78
|
+
ignoreDomain: !!(args === null || args === void 0 ? void 0 : args.ignoreDomain),
|
|
79
|
+
packageName: String(args.packageName),
|
|
80
|
+
silent: !!args.silent,
|
|
81
|
+
json: !!args.json,
|
|
82
|
+
location: !!(args === null || args === void 0 ? void 0 : args.location),
|
|
83
|
+
output: !!(args === null || args === void 0 ? void 0 : args.output),
|
|
84
|
+
fileComment: args.fileComment
|
|
85
|
+
? String(args.fileComment)
|
|
86
|
+
: undefined,
|
|
87
|
+
skip: {
|
|
88
|
+
js: !!args.skipJs,
|
|
89
|
+
php: !!args.skipPhp,
|
|
90
|
+
blade: !!args.skipBlade,
|
|
91
|
+
blockJson: !!args.skipBlockJson,
|
|
92
|
+
themeJson: !!args.skipThemeJson,
|
|
93
|
+
audit: !!args.skipAudit,
|
|
94
|
+
},
|
|
95
|
+
},
|
|
96
|
+
headers: {
|
|
97
|
+
fileComment: (_b = args.fileComment) !== null && _b !== void 0 ? _b : '',
|
|
98
|
+
},
|
|
99
|
+
patterns: {
|
|
100
|
+
mergePaths: (_c = (0, utils_1.stringstring)(args.mergePaths)) !== null && _c !== void 0 ? _c : [],
|
|
101
|
+
subtractPaths: (_d = (0, utils_1.stringstring)(args.subtractPaths)) !== null && _d !== void 0 ? _d : [],
|
|
102
|
+
subtractAndMerge: !!args.subtractAndMerge,
|
|
103
|
+
include: (_e = (0, utils_1.stringstring)(args.include)) !== null && _e !== void 0 ? _e : ['**'],
|
|
104
|
+
exclude: (_f = (0, utils_1.stringstring)(args.exclude)) !== null && _f !== void 0 ? _f : const_1.DEFAULT_EXCLUDED_PATH,
|
|
105
|
+
},
|
|
106
|
+
};
|
|
107
|
+
parsedArgs.paths.root = args.root ? String(args.root) : undefined;
|
|
108
|
+
return parsedArgs;
|
|
109
|
+
}
|
|
110
|
+
exports.parseCliArgs = parseCliArgs;
|
|
111
|
+
//# sourceMappingURL=parseCli.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"parseCli.js","sourceRoot":"","sources":["../../src/cli/parseCli.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;AACA,oCAAuC;AACvC,2CAA4B;AAC5B,iDAAkC;AAClC,oCAAgD;AAEhD,mDAAwC;AAGxC,SAAS,eAAe,CAAC,cAAsB,GAAG,EAAE,IAAY;IAC/D,MAAM,uBAAuB,GAAG,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AC5B,CAAC,CAAC,MAAM,CAAC,IAAI,CAAC,WAAW,CAAC;gBAC1B,CAAC,CAAC,SAAS;YACZ,IAAI,EAAE;gBACL,EAAE,EAAE,CAAC,CAAC,IAAI,CAAC,MAAM;gBACjB,GAAG,EAAE,CAAC,CAAC,IAAI,CAAC,OAAO;gBACnB,KAAK,EAAE,CAAC,CAAC,IAAI,CAAC,SAAS;gBACvB,SAAS,EAAE,CAAC,CAAC,IAAI,CAAC,aAAa;gBAC/B,SAAS,EAAE,CAAC,CAAC,IAAI,CAAC,aAAa;gBAC/B,KAAK,EAAE,CAAC,CAAC,IAAI,CAAC,SAAS;aACvB;SACD;QAED,OAAO,EAAE;YACR,WAAW,EAAE,MAAC,IAAI,CAAC,WAAsB,mCAAI,EAAE;SAC/C;QAED,QAAQ,EAAE;YACT,UAAU,EAAE,MAAA,IAAA,oBAAY,EAAC,IAAI,CAAC,UAAoB,CAAC,mCAAI,EAAE;YACzD,aAAa,EAAE,MAAA,IAAA,oBAAY,EAAC,IAAI,CAAC,aAAuB,CAAC,mCAAI,EAAE;YAC/D,gBAAgB,EAAE,CAAC,CAAC,IAAI,CAAC,gBAAgB;YACzC,OAAO,EAAE,MAAA,IAAA,oBAAY,EAAC,IAAI,CAAC,OAAiB,CAAC,mCAAI,CAAC,IAAI,CAAC;YACvD,OAAO,EACN,MAAA,IAAA,oBAAY,EAAC,IAAI,CAAC,OAAiB,CAAC,mCAAI,6BAAqB;SAC9D;KACD,CAAA;IAED,UAAU,CAAC,KAAK,CAAC,IAAI,GAAG,IAAI,CAAC,IAAI,CAAC,CAAC,CAAC,MAAM,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,SAAS,CAAA;IAEjE,OAAO,UAAU,CAAA;AAClB,CAAC;AA3DD,oCA2DC"}
|
package/lib/cliArgs.js
CHANGED
|
@@ -33,6 +33,37 @@ const utils_1 = require("./utils");
|
|
|
33
33
|
const path = __importStar(require("path"));
|
|
34
34
|
const process = __importStar(require("process"));
|
|
35
35
|
const const_1 = require("./const");
|
|
36
|
+
const node_fs_1 = __importStar(require("node:fs"));
|
|
37
|
+
function isThemeOrPlugin(currentPath = '/', slug) {
|
|
38
|
+
const currentWorkingDirectory = currentPath;
|
|
39
|
+
try {
|
|
40
|
+
(0, node_fs_1.accessSync)(path.join(currentWorkingDirectory, slug + '.php'), node_fs_1.default.constants.R_OK);
|
|
41
|
+
return 'plugin';
|
|
42
|
+
}
|
|
43
|
+
catch (err) {
|
|
44
|
+
console.log('the current working directory ' +
|
|
45
|
+
currentWorkingDirectory +
|
|
46
|
+
' does not contain a ' +
|
|
47
|
+
slug +
|
|
48
|
+
'.php file');
|
|
49
|
+
}
|
|
50
|
+
try {
|
|
51
|
+
(0, node_fs_1.accessSync)(path.join(currentWorkingDirectory, 'style.css'), node_fs_1.default.constants.R_OK);
|
|
52
|
+
return 'theme';
|
|
53
|
+
}
|
|
54
|
+
catch (err) {
|
|
55
|
+
console.log('the current working directory ' +
|
|
56
|
+
currentWorkingDirectory +
|
|
57
|
+
' does not contain a style.css file');
|
|
58
|
+
}
|
|
59
|
+
if (currentWorkingDirectory.includes('themes')) {
|
|
60
|
+
return 'theme';
|
|
61
|
+
}
|
|
62
|
+
else if (currentWorkingDirectory.includes('plugins')) {
|
|
63
|
+
return 'plugin';
|
|
64
|
+
}
|
|
65
|
+
return 'generic';
|
|
66
|
+
}
|
|
36
67
|
function getArgs() {
|
|
37
68
|
const args = (0, yargs_1.default)((0, helpers_1.hideBin)(process.argv))
|
|
38
69
|
.help('h')
|
|
@@ -140,15 +171,17 @@ function parseCliArgs(args) {
|
|
|
140
171
|
var _a, _b, _c, _d, _e, _f, _g;
|
|
141
172
|
const inputPath = typeof args._[0] === 'string' ? args._[0] : '.';
|
|
142
173
|
const outputPath = typeof args._[1] === 'string' ? args._[1] : '.';
|
|
174
|
+
const currentWorkingDirectory = process.cwd();
|
|
175
|
+
const slug = args.slug && typeof args.slug === 'string'
|
|
176
|
+
? args.slug
|
|
177
|
+
: path.basename(path.resolve(currentWorkingDirectory, inputPath));
|
|
178
|
+
const cwd = path.relative(currentWorkingDirectory, inputPath);
|
|
179
|
+
const out = path.relative(currentWorkingDirectory, outputPath);
|
|
180
|
+
const domain = (_a = args === null || args === void 0 ? void 0 : args.domain) !== null && _a !== void 0 ? _a : isThemeOrPlugin(path.resolve(cwd), slug);
|
|
143
181
|
const parsedArgs = {
|
|
144
|
-
slug:
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
domain: (_a = args === null || args === void 0 ? void 0 : args.domain) !== null && _a !== void 0 ? _a : 'generic',
|
|
148
|
-
paths: {
|
|
149
|
-
cwd: path.relative(process.cwd(), inputPath),
|
|
150
|
-
out: path.relative(process.cwd(), outputPath),
|
|
151
|
-
},
|
|
182
|
+
slug: slug,
|
|
183
|
+
domain: domain,
|
|
184
|
+
paths: { cwd: cwd, out: out },
|
|
152
185
|
options: {
|
|
153
186
|
ignoreDomain: !!(args === null || args === void 0 ? void 0 : args.ignoreDomain),
|
|
154
187
|
packageName: String((_b = args.packageName) !== null && _b !== void 0 ? _b : ''),
|