-
Notifications
You must be signed in to change notification settings - Fork 86
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
)" This reverts commit 0b1507a.
- Loading branch information
1 parent
b13d34f
commit c1351a3
Showing
77 changed files
with
3,034 additions
and
606 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,8 @@ | ||
missing-translations-strings.js | ||
language-mapping-list.js | ||
*.d.ts | ||
scripts/extensions/*/node_modules | ||
scripts/extensions/**/dist | ||
scripts/extensions/**/refs.d.ts | ||
end-to-end-testing-helpers/dist | ||
end-to-end-testing-helpers/node_modules | ||
spec/**/*.js |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,71 @@ | ||
const fs = require('fs'); | ||
const path = require('path'); | ||
var execSync = require('child_process').execSync; | ||
var _ = require('lodash'); | ||
|
||
function escapeSingleQuoteAsHtml(str) { | ||
return str.replace(/'/g, '''); | ||
} | ||
|
||
function unescapeSingleQuoteAsHtml(str) { | ||
return str.replace(/'/g, '\\\''); | ||
} | ||
|
||
function addTranslations(branch) { | ||
if (branch.properties == null) { | ||
return branch; | ||
} | ||
|
||
branch.translations = Object.keys(branch.properties).reduce((acc, property) => { | ||
// gettext call will be unwrapped from the string later with regex | ||
acc[property] = `gettext('${_.lowerCase(escapeSingleQuoteAsHtml(property))}')`; | ||
|
||
return acc; | ||
}, {}); | ||
|
||
for (const property of Object.keys(branch.properties)) { | ||
// handle nested properties | ||
branch.properties[property] = addTranslations(branch.properties[property]); | ||
|
||
// handle nested properties inside arrays | ||
if (branch.properties[property].items != null && branch.properties[property].items.properties != null) { | ||
branch.properties[property].items = addTranslations(branch.properties[property].items); | ||
} | ||
|
||
// translate description | ||
if (typeof branch.properties[property].description === 'string') { | ||
branch.properties[property].description = | ||
`gettext('${escapeSingleQuoteAsHtml(branch.properties[property].description)}')`; | ||
} | ||
} | ||
|
||
return branch; | ||
} | ||
|
||
function generateInstanceConfigurationSchema(clientDirAbs) { | ||
const file = path.join(clientDirAbs, 'node_modules/superdesk-core/scripts/core/superdesk-api.d.ts'); | ||
const configFile = path.join( | ||
clientDirAbs, | ||
'node_modules/superdesk-core/scripts/instance-settings.generated.ts' | ||
); | ||
const generatedSchema = JSON.parse( | ||
execSync(`npx typescript-json-schema "${file}" IInstanceSettings --strictNullChecks --required`).toString() | ||
); | ||
const schemaWithTranslations = unescapeSingleQuoteAsHtml( | ||
JSON.stringify(addTranslations(generatedSchema), null, 4) | ||
.replace(/"(gettext.+?)"/g, '$1') | ||
); | ||
|
||
const contents = | ||
`/* eslint-disable quotes, comma-dangle */ | ||
/* tslint:disable: trailing-comma max-line-length */ | ||
export const getInstanceConfigSchema = (gettext) => (${schemaWithTranslations}); | ||
`; | ||
|
||
fs.writeFileSync(configFile, contents, 'utf-8'); | ||
} | ||
|
||
module.exports = { | ||
generateInstanceConfigurationSchema, | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,10 +1,18 @@ | ||
// testing | ||
declare const describe: any; | ||
|
||
declare const xdescribe: any; | ||
|
||
declare const fdescribe: any; | ||
|
||
declare const beforeEach: any; | ||
|
||
declare const afterEach: any; | ||
|
||
declare const expect: any; | ||
|
||
declare const it: any; | ||
|
||
declare const fit: any; | ||
|
||
declare const xit: any; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.