@tangelo/tangelo-configuration-toolkit 1.14.3 → 1.14.4

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.
@@ -4,33 +4,32 @@
4
4
  repos:
5
5
 
6
6
  - repo: https://github.com/pre-commit/pre-commit-hooks
7
- rev: v3.2.0
7
+ rev: v4.4.0
8
8
  hooks:
9
9
  - id: trailing-whitespace
10
10
  - id: check-json
11
- - id: check-xml
12
11
  - id: check-merge-conflict # checks for files that contain merge conflict strings
13
12
  - id: check-added-large-files
14
13
  args: [--maxkb=100]
15
14
 
16
15
  - repo: https://github.com/pre-commit/pygrep-hooks
17
- rev: v1.9.0
16
+ rev: v1.10.0
18
17
  hooks:
19
18
  - id: text-unicode-replacement-char # forbid files which have a UTF-8 Unicode replacement character
20
19
 
21
- - repo: https://github.com/crate-ci/typos
22
- rev: v1.12.14
23
- hooks:
24
- - id: typos # spell checker
25
-
26
20
  - repo: https://github.com/macisamuele/language-formatters-pre-commit-hooks
27
- rev: v2.4.0
21
+ rev: v2.10.0
28
22
  hooks:
29
23
  - id: pretty-format-yaml
30
24
  args: [--autofix, --indent, '2']
31
25
 
32
26
  - repo: https://github.com/pre-commit/mirrors-eslint
33
- rev: v8.28.0
27
+ rev: v8.49.0
34
28
  hooks:
35
29
  - id: eslint # javascript linter and formatter
36
30
  args: [--fix]
31
+
32
+ - repo: https://github.com/crate-ci/typos
33
+ rev: v1.16.11
34
+ hooks:
35
+ - id: typos # spell checker
@@ -0,0 +1,6 @@
1
+ {
2
+ "sonarlint.connectedMode.project": {
3
+ "connectionId": "tangelosoftware",
4
+ "projectKey": "tangelosoftware_tangelo-configuration-toolkit"
5
+ }
6
+ }
package/README.md CHANGED
@@ -1,67 +1,67 @@
1
- # tangelo-configuration-toolkit
2
-
3
- Tangelo Configuration Toolkit is a command-line toolkit which offers support for developing a Tangelo configuration.
4
-
5
- ## Installation
6
-
7
- The toolkit requires [NPM](https://www.npmjs.com/get-npm) on [Node.js®](https://nodejs.org/) (at least version 14.x). An active or maintenance LTS release is recommended. After installing Node.js, you can install the latest version of the Tangelo Configuration Toolkit globally on your system using the following command:
8
-
9
- npm i -g @tangelo/tangelo-configuration-toolkit
10
-
11
- ## Usage
12
-
13
- Get help for the available commands and see version:
14
-
15
- tangelo-configuration-toolkit
16
-
17
- Get help for a specific command, detailing all its arguments:
18
-
19
- tangelo-configuration-toolkit <command>
20
-
21
- Use the `tct` shorthand instead of `tangelo-configuration-toolkit`:
22
-
23
- tct <command>
24
-
25
- ## Config
26
-
27
- ### Global
28
-
29
- The `deploy` command requires server connection information. So you'll have to create a configuration file named `tangelo-configuration-toolkit-appconfig.json` in which such information can be stored. This file will be searched for in an ancestor directory of the current working directory.
30
-
31
- The contents looks like this (all properties are optional):
32
-
33
- {
34
- "sharedConfigPath": "absolute/or/relative/path/to/folder/containing/shared/config",
35
- "servers": [{
36
- "config": {
37
- "port": 22,
38
- "parallel": 4,
39
- "username": "username",
40
- "remotedir": "/absolute/path/to/tangelo/config/folder/on/server"
41
- },
42
- "domains": ["domain.name.com"],
43
- "name": "name-for-local-deploy"
44
- }],
45
- "serverDefaults": {
46
- "config": {
47
- ...
48
- }
49
- }
50
- "defaultServer": "can be set to the name of e.g. your favorite dev server",
51
- "defaultDatabase": "can be set to the tnsname of e.g. your favorite dev server"
52
- }
53
-
54
- When passing a server name, `tct` will look for a full match with a name or a partial match (the start) with a domain.
55
-
56
- ### Repo
57
-
58
- The `build` and `sql` commands make use of a configuration file in the repository named `tangelo-configuration-toolkit-repoconfig.json`. This contains information about the customer projects.
59
-
60
- For a new repository, using `tct build --init` also creates the repoconfig-file. For existing projects not having the repoconfig-file, you can use `tct build --config` to generate it.
61
-
62
- ### oXygen
63
-
64
- The `build -x` commands set projects transformation scenarios and masterfiles in the oXygen project file with the following functionality:
65
- - Will try to preserve manually added entries in the transformation scenarios and masterfiles
66
- - Will remove non existing masterfiles or masterfiles that start with a '_'
67
- - No masterfiles / scenarios will be added if their path match with oXygens hidden directory patterns
1
+ # tangelo-configuration-toolkit
2
+
3
+ Tangelo Configuration Toolkit is a command-line toolkit which offers support for developing a Tangelo configuration.
4
+
5
+ ## Installation
6
+
7
+ The toolkit requires [NPM](https://www.npmjs.com/get-npm) on [Node.js®](https://nodejs.org/) (at least version 18.x). An active or maintenance LTS release is recommended. After installing Node.js, you can install the latest version of the Tangelo Configuration Toolkit globally on your system using the following command:
8
+
9
+ npm i -g @tangelo/tangelo-configuration-toolkit
10
+
11
+ ## Usage
12
+
13
+ Get help for the available commands and see version:
14
+
15
+ tangelo-configuration-toolkit
16
+
17
+ Get help for a specific command, detailing all its arguments:
18
+
19
+ tangelo-configuration-toolkit <command>
20
+
21
+ Use the `tct` shorthand instead of `tangelo-configuration-toolkit`:
22
+
23
+ tct <command>
24
+
25
+ ## Config
26
+
27
+ ### Global
28
+
29
+ The `deploy` command requires server connection information. So you'll have to create a configuration file named `tangelo-configuration-toolkit-appconfig.json` in which such information can be stored. This file will be searched for in an ancestor directory of the current working directory.
30
+
31
+ The contents looks like this (all properties are optional):
32
+
33
+ {
34
+ "sharedConfigPath": "absolute/or/relative/path/to/folder/containing/shared/config",
35
+ "servers": [{
36
+ "config": {
37
+ "port": 22,
38
+ "parallel": 4,
39
+ "username": "username",
40
+ "remotedir": "/absolute/path/to/tangelo/config/folder/on/server"
41
+ },
42
+ "domains": ["domain.name.com"],
43
+ "name": "name-for-local-deploy"
44
+ }],
45
+ "serverDefaults": {
46
+ "config": {
47
+ ...
48
+ }
49
+ }
50
+ "defaultServer": "can be set to the name of e.g. your favorite dev server",
51
+ "defaultDatabase": "can be set to the tnsname of e.g. your favorite dev server"
52
+ }
53
+
54
+ When passing a server name, `tct` will look for a full match with a name or a partial match (the start) with a domain.
55
+
56
+ ### Repo
57
+
58
+ The `build` and `sql` commands make use of a configuration file in the repository named `tangelo-configuration-toolkit-repoconfig.json`. This contains information about the customer projects.
59
+
60
+ For a new repository, using `tct build --init` also creates the repoconfig-file. For existing projects not having the repoconfig-file, you can use `tct build --config` to generate it.
61
+
62
+ ### oXygen
63
+
64
+ The `build -x` commands set projects transformation scenarios and masterfiles in the oXygen project file with the following functionality:
65
+ - Will try to preserve manually added entries in the transformation scenarios and masterfiles
66
+ - Will remove non existing masterfiles or masterfiles that start with a '_'
67
+ - No masterfiles / scenarios will be added if their path match with oXygens hidden directory patterns
package/bin/index.js CHANGED
@@ -1,3 +1,3 @@
1
- #!/usr/bin/env node
2
-
1
+ #!/usr/bin/env node
2
+
3
3
  require('..');
@@ -13,20 +13,20 @@ definitions:
13
13
  - step: &build-test-sonarcloud
14
14
  name: Build, test and analyze on SonarCloud
15
15
  caches:
16
- - sonar
16
+ - sonar
17
17
  script:
18
- - pipe: sonarsource/sonarcloud-scan:1.4.0
18
+ - pipe: sonarsource/sonarcloud-scan:2.0.0
19
19
  - step: &check-quality-gate-sonarcloud
20
20
  name: Check the Quality Gate on SonarCloud
21
21
  script:
22
- - pipe: sonarsource/sonarcloud-quality-gate:0.1.6
22
+ - pipe: sonarsource/sonarcloud-quality-gate:0.1.6
23
23
 
24
24
  pipelines:
25
25
  branches:
26
26
  master:
27
- - step: *build-test-sonarcloud
28
- - step: *check-quality-gate-sonarcloud
27
+ - step: *build-test-sonarcloud
28
+ - step: *check-quality-gate-sonarcloud
29
29
  pull-requests:
30
30
  '**':
31
- - step: *build-test-sonarcloud
32
- - step: *check-quality-gate-sonarcloud
31
+ - step: *build-test-sonarcloud
32
+ - step: *check-quality-gate-sonarcloud
package/index.js CHANGED
@@ -30,23 +30,23 @@ global._info = (msg, time = false) => {
30
30
  console.log(msg.lgreen);
31
31
  };
32
32
 
33
- global._warn = (msg) => {
33
+ global._warn = msg => {
34
34
  console.log(msg.lyellow);
35
35
  };
36
36
 
37
- global._error = (msg) => {
37
+ global._error = msg => {
38
38
  console.log(msg.red, '\n');
39
39
  process.exit();
40
40
  };
41
41
 
42
- global._perf = (t1) => {
42
+ global._perf = t1 => {
43
43
  const t2 = new Date();
44
44
  console.log(`\nExecution time: ${t2 - t1}ms`.blue);
45
45
  };
46
46
 
47
- global._formatDate = (date) => {
48
- return date.toLocaleDateString('en-gb', {day: 'numeric', month: 'short', year: 'numeric', hour: '2-digit', minute: '2-digit'});
49
- };
47
+ global._formatDate = date =>
48
+ date?.toLocaleDateString('en-gb', {day: 'numeric', month: 'short', year: 'numeric', hour: '2-digit', minute: '2-digit'});
49
+ ;
50
50
 
51
51
  global._paths = {
52
52
  app: __dirname,
@@ -61,7 +61,7 @@ _paths.apply = process.cwd().replace(_paths.repo, '').substr(1);
61
61
 
62
62
 
63
63
  global._appdata = fs.readJsonSync(_paths.appdata, {throws: false}) || {};
64
- _appdata._update = (data) => Object.assign(_appdata, data, {_changed: true});
64
+ _appdata._update = data => Object.assign(_appdata, data, {_changed: true});
65
65
  if (!_appdata.npmPath) {
66
66
  _appdata._update({npmPath: execSync('npm config get prefix', {encoding: 'UTF-8'}).replace(/\s$/, '')});
67
67
  }
@@ -112,7 +112,7 @@ global._git = {
112
112
 
113
113
 
114
114
  if (_git.commitTdi.after(_git.commitTdi.stopUsingRepoconfigFile)) {
115
- global._repoconfig = require('./src/lib/get-repoconfig')();
115
+ global._repoconfig = require('./src/lib/get-repoconfig')(_paths.repo);
116
116
  }
117
117
  else {
118
118
  try { global._repoconfig = fs.existsSync(_paths.repoconfig) && fs.readJsonSync(_paths.repoconfig) || {}; }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tangelo/tangelo-configuration-toolkit",
3
- "version": "1.14.3",
3
+ "version": "1.14.4",
4
4
  "engines": {
5
5
  "node": ">=14.0.0"
6
6
  },
@@ -28,7 +28,7 @@
28
28
  "del": "^6.0.0",
29
29
  "event-stream": "^4.0.1",
30
30
  "find-up": "^5.0.0",
31
- "fs-extra": "^10.0.0",
31
+ "fs-extra": "^11.1.1",
32
32
  "globby": "^6.1.0",
33
33
  "gulp": "^4.0.2",
34
34
  "gulp-babel": "^8.0.0",
@@ -40,17 +40,17 @@
40
40
  "gulp-sourcemaps": "^3.0.0",
41
41
  "inquirer": "^8.2.0",
42
42
  "istextorbinary": "^6.0.0",
43
- "minimatch": "^5.0.0",
44
- "node-ssh": "^12.0.2",
43
+ "minimatch": "^8.0.4",
44
+ "node-ssh": "^13.1.0",
45
45
  "object-assign-deep": "^0.4.0",
46
46
  "p-limit": "^3.1.0",
47
47
  "replace-in-file": "^6.3.2",
48
48
  "sass": "^1.43.5",
49
49
  "saxon-js": "^2.3.0",
50
- "ssh2-sftp-client": "^7.2.2",
50
+ "ssh2-sftp-client": "^9.1.0",
51
51
  "through2": "^4.0.2",
52
52
  "tiny-lr": "^2.0.0",
53
- "yargs": "^16.2.0"
53
+ "yargs": "^17.7.2"
54
54
  },
55
55
  "repository": {
56
56
  "type": "git",
@@ -2,12 +2,12 @@ const fs = require('fs-extra');
2
2
  const globby = require('globby');
3
3
 
4
4
 
5
- module.exports = function getRepoconfig() {
5
+ module.exports = function getRepoconfig(repoPath) {
6
6
 
7
7
  const repoconfig = [];
8
8
 
9
9
  globby
10
- .sync('database/config/**/txd_document_types.sql')
10
+ .sync('database/config/**/txd_document_types.sql', {cwd: repoPath, absolute: true})
11
11
  .forEach(p => {
12
12
  const dtSqlInsert = fs.readFileSync(p).toString().match(/select(.*?)from/s)[1];
13
13
  const ntSqlInsert = fs.readFileSync(p.replace('txd_document_types', 'txd_node_types')).toString().match(/select(.*?)from/s)[1];
@@ -17,7 +17,7 @@ module.exports = function getRepoconfig() {
17
17
  const xpiDir = ntSqlInsert.match(/'([^']+)' xsl_prep_inc/)[1];
18
18
 
19
19
  const path_cmscustom = xpiDir.replace(/\/[^/]+$/, '').split(/\//);
20
- const path_dbconfig = p.replace(/database\/config\/(.*)\/[^/]+/, '$1').split(/[/\\]/);
20
+ const path_dbconfig = p.replace(/.*\/database\/config\/(.*)\/[^/]+/, '$1').split(/[/\\]/);
21
21
  const dnRegex = [path_cmscustom[0].replace(/[_'"]/g, '.'), path_dbconfig[0].replace(/[_'"]/g, '.')].sort((a, b) => b.length - a.length).join('|');
22
22
  const customer_name = (dtDisplayName.match(RegExp(dnRegex, 'i')) || dtDisplayName.split(/ (.+)/))[0];
23
23
 
@@ -1,44 +1,44 @@
1
- const execGitCommand = require('./exec-git-command');
2
- const path = require('path');
3
-
4
- module.exports = function getTdiBranch(toBranchName) {
5
- const tdiBranch = {};
6
- // Fetch all
7
- _info(`Fetch TDI submodule`);
8
- const cmdFetch = execGitCommand('fetch -pf --all', path.join(_paths.repo, _paths.tdi));
9
- if (cmdFetch.error) _warn(`Fetch failed\n${cmdFetch.error}`);
10
-
11
- let toBranch;
12
- if (toBranchName) {
13
- // Check if specified branch exists; we will update to this branch
14
- toBranch = String(toBranchName).replace(/(?:release\/)?(\d+(?:\.[\dxt]+)*)/, `release/$1`);
15
- const branchExists = execGitCommand(`branch --remote`, path.join(_paths.repo, _paths.tdi)).match(`origin/${toBranch}`);
16
- if (!branchExists) _error(`TDI branch "${toBranch}" does not exist. Note that TCT can only update to a release branch.`);
17
- }
18
-
19
- // Get remote release branches containing TDI HEAD commit
20
- const releaseBranches = execGitCommand(`branch --all --contains ${_git.commitTdi.local().hash}`, path.join(_paths.repo, _paths.tdi)).match(/remotes\/origin\/release\/[^\s]+/gsm);
21
- if (!releaseBranches || releaseBranches.error) _error(`Could not retrieve TDI release branches`);
22
-
23
- // Get the first possible branch; prefer release/5.1 over release/5.2:
24
- releaseBranches.sort((a, b) => a > b ? 1 : -1);
25
-
26
- // Set branch name of firstBranch without 'remotes/origin/'
27
- tdiBranch.name = releaseBranches[0].replace(/remotes\/origin\//g, '');
28
-
29
- // In case of branch switch set from.name to the old branch and name to the new branch
30
- if (toBranch) {
31
- if (tdiBranch.name > toBranch) _error(`You cannot downgrade to a lower release branch with TCT.`);
32
- tdiBranch.from = {name: tdiBranch.name};
33
- tdiBranch.name = toBranch;
34
-
35
- const branchHash = execGitCommand(`rev-parse origin/${toBranch}`, path.join(_paths.repo, _paths.tdi));
36
- const commonAncestorHash = execGitCommand(`merge-base ${_git.commitTdi.local().hash} ${branchHash}`, path.join(_paths.repo, _paths.tdi));
37
- const commonAncestorDate = execGitCommand(`show ${commonAncestorHash} --no-patch --format=%cd --date=iso-strict `, path.join(_paths.repo, _paths.tdi), ['date']).date;
38
- tdiBranch.commonAncestor = {date: new Date(commonAncestorDate)};
39
- }
40
-
41
- // Get number of commits behind
42
- tdiBranch.commitsBehind = execGitCommand(`rev-list HEAD...origin/${tdiBranch.name} --count`, path.join(_paths.repo, _paths.tdi));
43
- return tdiBranch;
1
+ const execGitCommand = require('./exec-git-command');
2
+ const path = require('path');
3
+
4
+ module.exports = function getTdiBranch(toBranchName) {
5
+ const tdiBranch = {};
6
+ // Fetch all
7
+ _info(`Fetch TDI submodule`);
8
+ const cmdFetch = execGitCommand('fetch -pf --all', path.join(_paths.repo, _paths.tdi));
9
+ if (cmdFetch.error) _warn(`Fetch failed\n${cmdFetch.error}`);
10
+
11
+ let toBranch;
12
+ if (toBranchName) {
13
+ // Check if specified branch exists; we will update to this branch
14
+ toBranch = String(toBranchName).replace(/(?:release\/)?(\d+(?:\.[\dxt]+)*)/, `release/$1`);
15
+ const branchExists = execGitCommand(`branch --remote`, path.join(_paths.repo, _paths.tdi)).match(`origin/${toBranch}`);
16
+ if (!branchExists) _error(`TDI branch "${toBranch}" does not exist. Note that TCT can only update to a release branch.`);
17
+ }
18
+
19
+ // Get remote release branches containing TDI HEAD commit
20
+ const releaseBranches = execGitCommand(`branch --all --contains ${_git.commitTdi.local().hash}`, path.join(_paths.repo, _paths.tdi)).match(/remotes\/origin\/release\/[^\s]+/gsm);
21
+ if (!releaseBranches || releaseBranches.error) _error(`Could not retrieve TDI release branches`);
22
+
23
+ // Get the first possible branch; prefer release/5.1 over release/5.2:
24
+ releaseBranches.sort((a, b) => a > b ? 1 : -1);
25
+
26
+ // Set branch name of firstBranch without 'remotes/origin/'
27
+ tdiBranch.name = releaseBranches[0].replace(/remotes\/origin\//g, '');
28
+
29
+ // In case of branch switch set from.name to the old branch and name to the new branch
30
+ if (toBranch) {
31
+ if (tdiBranch.name > toBranch) _error(`You cannot downgrade to a lower release branch with TCT.`);
32
+ tdiBranch.from = {name: tdiBranch.name};
33
+ tdiBranch.name = toBranch;
34
+
35
+ const branchHash = execGitCommand(`rev-parse origin/${toBranch}`, path.join(_paths.repo, _paths.tdi));
36
+ const commonAncestorHash = execGitCommand(`merge-base ${_git.commitTdi.local().hash} ${branchHash}`, path.join(_paths.repo, _paths.tdi));
37
+ const commonAncestorDate = execGitCommand(`show ${commonAncestorHash} --no-patch --format=%cd --date=iso-strict `, path.join(_paths.repo, _paths.tdi), ['date']).date;
38
+ tdiBranch.commonAncestor = {date: new Date(commonAncestorDate)};
39
+ }
40
+
41
+ // Get number of commits behind
42
+ tdiBranch.commitsBehind = execGitCommand(`rev-list HEAD...origin/${tdiBranch.name} --count`, path.join(_paths.repo, _paths.tdi));
43
+ return tdiBranch;
44
44
  };
@@ -1,19 +1,19 @@
1
- // based on gulp-batch-replace
2
-
3
- const es = require('event-stream'), minimatch = require('minimatch'), istextorbinary = require('istextorbinary');
4
-
5
- const execReplace = (c, s, r) => Buffer.from(s instanceof RegExp ? String(c).replace(s, r) : String(c).split(s).join(r));
6
-
7
- module.exports = (arr) => {
8
- return es.map((file, callback) => {
9
- if(file.contents instanceof Buffer) {
10
- arr.forEach(e => {
11
- // exec if no glob is passed or if glob matches, and it's a text file
12
- if ((!e[2] || minimatch(file.path, e[2])) && istextorbinary.isText(file.path, file)) {
13
- file.contents = execReplace(file.contents, e[0], e[1]);
14
- }
15
- });
16
- }
17
- callback(null, file);
18
- });
19
- };
1
+ // based on gulp-batch-replace
2
+
3
+ const es = require('event-stream'), minimatch = require('minimatch'), istextorbinary = require('istextorbinary');
4
+
5
+ const execReplace = (c, s, r) => Buffer.from(s instanceof RegExp ? String(c).replace(s, r) : String(c).split(s).join(r));
6
+
7
+ module.exports = (arr) => {
8
+ return es.map((file, callback) => {
9
+ if(file.contents instanceof Buffer) {
10
+ arr.forEach(e => {
11
+ // exec if no glob is passed or if glob matches, and it's a text file
12
+ if ((!e[2] || minimatch(file.path, e[2])) && istextorbinary.isText(file.path, file)) {
13
+ file.contents = execReplace(file.contents, e[0], e[1]);
14
+ }
15
+ });
16
+ }
17
+ callback(null, file);
18
+ });
19
+ };
@@ -1,11 +1,11 @@
1
- // replacement for the official (but deprecated) gulp-simple-rename
2
- // kept same name because of usage in tdi
3
-
4
- const through2 = require('through2');
5
-
6
- module.exports = (fn) => {
7
- return through2.obj((file, enc, cb) => {
8
- file.path = fn(file.path);
9
- cb(null, file);
10
- });
11
- };
1
+ // replacement for the official (but deprecated) gulp-simple-rename
2
+ // kept same name because of usage in tdi
3
+
4
+ const through2 = require('through2');
5
+
6
+ module.exports = (fn) => {
7
+ return through2.obj((file, enc, cb) => {
8
+ file.path = fn(file.path);
9
+ cb(null, file);
10
+ });
11
+ };
@@ -1,3 +1,5 @@
1
+ /* eslint-disable no-control-regex */
2
+
1
3
  const styles = {bold: 1, underline: 4, black: 30, red: 31, green: 32, yellow: 33, blue: 34, magenta: 35, cyan: 36, white: 37, lblack: 90, lred: 91, lgreen: 92, lyellow: 93, lblue: 94, lmagenta: 95, lcyan: 96, lwhite: 97};
2
4
 
3
5
  for (const name in styles ) {