wp-advads 1.0.31 → 1.0.34
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/workflows/test.yml +17 -0
- package/CHANGELOG.md +23 -1
- package/LICENSE +15 -0
- package/README.md +8 -7
- package/package.json +9 -7
- package/src/app.js +17 -11
- package/src/commands/build.js +72 -59
- package/src/commands/class.js +34 -40
- package/src/commands/css.js +13 -19
- package/src/commands/init.js +4 -1
- package/src/commands/javascript.js +13 -19
- package/src/commands/release/change-version.js +14 -17
- package/src/commands/release/changelog.js +23 -31
- package/src/commands/release/git.js +25 -13
- package/src/commands/release/github.js +63 -12
- package/src/commands/release/semver.js +22 -25
- package/src/commands/release/translations.js +17 -23
- package/src/commands/release.js +3 -4
- package/src/commands/updates.js +20 -17
- package/src/commands/views.js +16 -18
- package/src/commands/wp-glotpress.js +125 -126
- package/src/commands/wp-pot.js +17 -9
- package/src/utilities/filesystem.js +57 -36
- package/src/utilities/flow.js +21 -0
- package/src/utilities/formatting.js +13 -4
- package/src/utilities/index.js +1 -1
- package/src/utilities/misc.js +1 -6
- package/src/utilities/settings.js +34 -14
- package/src/utilities/shell.js +60 -8
- package/template/files/class-singleton.php +5 -0
- package/template/files/javascript.js +0 -2
- package/template/files/view.php +2 -0
- package/test/build.test.js +168 -0
- package/test/changelog-locales.test.js +49 -0
- package/test/class.test.js +47 -0
- package/test/compile-templates.test.js +70 -0
- package/test/deps-hygiene.test.js +46 -0
- package/test/engines.test.js +11 -0
- package/test/get-latest-tag.test.js +51 -0
- package/test/git-precheck.test.js +44 -0
- package/test/github-final.test.js +93 -0
- package/test/glotpress-download.test.js +176 -0
- package/test/nested-path.test.js +39 -0
- package/test/no-fs-extra.test.js +11 -0
- package/test/package-identity.test.js +19 -0
- package/test/path-confine.test.js +42 -0
- package/test/pot-docs.test.js +27 -0
- package/test/pot-headers.test.js +49 -0
- package/test/project-root.test.js +26 -0
- package/test/release-waterfall.test.js +62 -0
- package/test/semver.test.js +25 -0
- package/test/settings-clone.test.js +34 -0
- package/test/settings-path.test.js +31 -0
- package/test/shell.test.js +100 -0
- package/test/singleton.test.js +14 -0
- package/test/stable-tag.test.js +13 -0
- package/test/stub-security.test.js +37 -0
- package/test/template-folder.test.js +19 -0
- package/test/translations.test.js +51 -0
- package/test/update-file-content.test.js +38 -0
- package/test/updates.test.js +39 -0
- package/test/version.test.js +22 -0
- package/test/view-escape.test.js +17 -0
- package/test/view.test.js +33 -0
- package/test/write-force.test.js +47 -0
- package/src/utilities/semver.js +0 -45
- package/template/.github/pull_request_template.md +0 -52
- package/template/configs/.editorconfig +0 -27
- package/template/configs/.eslintignore +0 -13
- package/template/configs/.eslintrc.js +0 -13
- package/template/configs/.phpcs.xml.dist +0 -87
- package/template/configs/.prettierignore +0 -49
- package/template/configs/.prettierrc.js +0 -3
- package/template/configs/.stylelintrc +0 -44
- package/template/configs/composer.json +0 -51
- package/template/configs/gitattributes +0 -34
- package/template/configs/gitignore +0 -43
- package/template/configs/package.json +0 -66
- package/template/configs/postcss.config.js +0 -6
- package/template/configs/tailwind.config.js +0 -8
- package/template/configs/webpack.mix.js +0 -65
- package/template/configs/webpack.mix.local.js +0 -3
- package/template/includes/index.php +0 -2
- package/template/index.js +0 -0
- package/template/index.php +0 -4
- package/template/plugin/assets/scss/app.scss +0 -0
- package/template/plugin/assets/src/app.js +0 -0
- package/template/tools/laravel-mix/wp-pot.js +0 -57
- package/template/tools/wp-glotpress.js +0 -162
|
@@ -1,162 +0,0 @@
|
|
|
1
|
-
#!/usr/bin/env node
|
|
2
|
-
/* eslint-disable no-console */
|
|
3
|
-
|
|
4
|
-
// Packages.
|
|
5
|
-
const chalk = require('chalk');
|
|
6
|
-
const fs = require('fs');
|
|
7
|
-
const { resolve } = require('path');
|
|
8
|
-
const async = require('async');
|
|
9
|
-
|
|
10
|
-
const packageDetails = require('../package.json');
|
|
11
|
-
class GlotPressDownloader {
|
|
12
|
-
baseURL = 'https://translate.wpadvancedads.com/api/projects';
|
|
13
|
-
|
|
14
|
-
log(msg) {
|
|
15
|
-
if (!this.isNoConsole) {
|
|
16
|
-
console.log(msg);
|
|
17
|
-
}
|
|
18
|
-
}
|
|
19
|
-
|
|
20
|
-
run() {
|
|
21
|
-
this.isNoConsole = process.argv.includes('--no-console');
|
|
22
|
-
|
|
23
|
-
try {
|
|
24
|
-
this.log(
|
|
25
|
-
chalk
|
|
26
|
-
.hex('#FADC00')
|
|
27
|
-
.inverse.bold('Downloading Translations from GlotPress')
|
|
28
|
-
);
|
|
29
|
-
this.validateData();
|
|
30
|
-
this.maybeDirectory();
|
|
31
|
-
this.download();
|
|
32
|
-
} catch (error) {
|
|
33
|
-
this.log(chalk.bgRed.bold('Error:') + ' ' + error.message);
|
|
34
|
-
}
|
|
35
|
-
}
|
|
36
|
-
|
|
37
|
-
async download() {
|
|
38
|
-
const locales = await this.getGlotPressData();
|
|
39
|
-
|
|
40
|
-
if (false === locales) {
|
|
41
|
-
return;
|
|
42
|
-
}
|
|
43
|
-
|
|
44
|
-
// Download files.
|
|
45
|
-
async.map(
|
|
46
|
-
Object.keys(locales),
|
|
47
|
-
(locale, callback) => {
|
|
48
|
-
const localeData = locales[locale];
|
|
49
|
-
|
|
50
|
-
this.log('');
|
|
51
|
-
this.log(
|
|
52
|
-
chalk.yellow.bold('Updating Language:') +
|
|
53
|
-
` ${chalk.italic(localeData.name)}`
|
|
54
|
-
);
|
|
55
|
-
|
|
56
|
-
async.map(['mo', 'po'], (format) => {
|
|
57
|
-
if (this.isNoConsole) {
|
|
58
|
-
process.stdout.write(
|
|
59
|
-
`${this.destination.replace('./', '')}${
|
|
60
|
-
this.potPrefix
|
|
61
|
-
}-${locale}.${format}=${localeData.name}` + '\n'
|
|
62
|
-
);
|
|
63
|
-
}
|
|
64
|
-
this.downloadFile(locale, localeData, format);
|
|
65
|
-
});
|
|
66
|
-
|
|
67
|
-
callback(null, true);
|
|
68
|
-
},
|
|
69
|
-
() => {
|
|
70
|
-
this.log('');
|
|
71
|
-
this.log(
|
|
72
|
-
chalk.bgGreen.bold('Success:') +
|
|
73
|
-
' All files has been downloaded.'
|
|
74
|
-
);
|
|
75
|
-
}
|
|
76
|
-
);
|
|
77
|
-
}
|
|
78
|
-
|
|
79
|
-
validateData() {
|
|
80
|
-
if (
|
|
81
|
-
undefined === packageDetails.glotpress ||
|
|
82
|
-
Object.keys(packageDetails.glotpress).length < 1
|
|
83
|
-
) {
|
|
84
|
-
throw new Error('The GlotPress settings is not defined.');
|
|
85
|
-
}
|
|
86
|
-
|
|
87
|
-
if (
|
|
88
|
-
undefined === packageDetails.glotpress.project ||
|
|
89
|
-
('' === undefined) === packageDetails.glotpress.project
|
|
90
|
-
) {
|
|
91
|
-
throw new Error('The GlotPress project name is not defined.');
|
|
92
|
-
}
|
|
93
|
-
|
|
94
|
-
if (
|
|
95
|
-
undefined === packageDetails.glotpress.destination ||
|
|
96
|
-
('' === undefined) === packageDetails.glotpress.destination
|
|
97
|
-
) {
|
|
98
|
-
throw new Error('The destination directory is not defined.');
|
|
99
|
-
}
|
|
100
|
-
|
|
101
|
-
// Set data.
|
|
102
|
-
const { project, destination } = packageDetails.glotpress;
|
|
103
|
-
const { domain } = packageDetails.wpPot;
|
|
104
|
-
|
|
105
|
-
this.project = project;
|
|
106
|
-
this.potPrefix = domain ?? project;
|
|
107
|
-
this.destination = destination;
|
|
108
|
-
}
|
|
109
|
-
|
|
110
|
-
maybeDirectory() {
|
|
111
|
-
const destination = resolve(this.destination);
|
|
112
|
-
|
|
113
|
-
if (!fs.existsSync(destination)) {
|
|
114
|
-
fs.mkdirSync(destination);
|
|
115
|
-
}
|
|
116
|
-
}
|
|
117
|
-
|
|
118
|
-
async getGlotPressData() {
|
|
119
|
-
const response = await fetch(`${this.baseURL}/${this.project}`);
|
|
120
|
-
const data = await response.json();
|
|
121
|
-
const sets = {};
|
|
122
|
-
|
|
123
|
-
if (undefined !== data.success && !data.success) {
|
|
124
|
-
this.log(chalk.bgRed.bold('Error:') + ' ' + data.error);
|
|
125
|
-
return false;
|
|
126
|
-
}
|
|
127
|
-
|
|
128
|
-
data.translation_sets.map((set) => {
|
|
129
|
-
if (set.current_count > 0) {
|
|
130
|
-
let id = set.wp_locale;
|
|
131
|
-
if ('default' !== set.slug) {
|
|
132
|
-
id += '_' + set.slug;
|
|
133
|
-
}
|
|
134
|
-
|
|
135
|
-
sets[id] = set;
|
|
136
|
-
}
|
|
137
|
-
|
|
138
|
-
return false;
|
|
139
|
-
});
|
|
140
|
-
|
|
141
|
-
return sets;
|
|
142
|
-
}
|
|
143
|
-
|
|
144
|
-
// Download Handler.
|
|
145
|
-
async downloadFile(locale, data, format) {
|
|
146
|
-
this.log(
|
|
147
|
-
chalk.bold(`Downloading: ${this.potPrefix}-${locale}.${format}`)
|
|
148
|
-
);
|
|
149
|
-
|
|
150
|
-
const target = `${this.destination}/${this.potPrefix}-${locale}.${format}`;
|
|
151
|
-
const endpoint = `${this.baseURL}/${this.project}/${data.locale}/${data.slug}/export-translations?format=${format}`;
|
|
152
|
-
|
|
153
|
-
// Download.
|
|
154
|
-
const response = await fetch(endpoint);
|
|
155
|
-
const content = await response.text();
|
|
156
|
-
|
|
157
|
-
fs.writeFileSync(target, content);
|
|
158
|
-
}
|
|
159
|
-
}
|
|
160
|
-
|
|
161
|
-
const downlaoder = new GlotPressDownloader();
|
|
162
|
-
downlaoder.run();
|