@koobiq/components 18.6.0 → 18.7.1

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.
@@ -0,0 +1,97 @@
1
+ 'use strict';
2
+
3
+ Object.defineProperty(exports, '__esModule', { value: true });
4
+
5
+ var path = require('path');
6
+ var utils_messages = require('../../utils/messages.js');
7
+ var utils_packageConfig = require('../../utils/package-config.js');
8
+ var migrations_deprecatedIcons_data = require('./data.js');
9
+ require('@angular-devkit/schematics');
10
+ require('@schematics/angular/utility');
11
+
12
+ function _interopNamespaceDefault(e) {
13
+ var n = Object.create(null);
14
+ if (e) {
15
+ Object.keys(e).forEach(function (k) {
16
+ if (k !== 'default') {
17
+ var d = Object.getOwnPropertyDescriptor(e, k);
18
+ Object.defineProperty(n, k, d.get ? d : {
19
+ enumerable: true,
20
+ get: function () { return e[k]; }
21
+ });
22
+ }
23
+ });
24
+ }
25
+ n.default = e;
26
+ return Object.freeze(n);
27
+ }
28
+
29
+ var path__namespace = /*#__PURE__*/_interopNamespaceDefault(path);
30
+
31
+ const iconsFontImportRule = "@use '@koobiq/icons/fonts/kbq-icons';";
32
+ function deprecatedIcons(options) {
33
+ let targetDir;
34
+ return async (tree, context) => {
35
+ const { project, fix, stylesExt } = options;
36
+ try {
37
+ const projectDefinition = await utils_packageConfig.setupOptions(project, tree);
38
+ targetDir = projectDefinition ? tree.getDir(projectDefinition.root) : tree;
39
+ }
40
+ catch (e) {
41
+ targetDir = tree;
42
+ }
43
+ const { logger } = context;
44
+ const handleDeprecatedIcons = (newContent, filePath) => {
45
+ if (fix) {
46
+ migrations_deprecatedIcons_data.iconsMapping.forEach(({ replace, replaceWith }) => {
47
+ newContent = newContent.replace(new RegExp(`kbq-${replace}`, 'g'), `kbq-${replaceWith}`);
48
+ });
49
+ }
50
+ else {
51
+ const foundIcons = migrations_deprecatedIcons_data.iconsMapping.filter(({ replace }) => newContent.indexOf(replace) !== -1);
52
+ if (foundIcons.length) {
53
+ const parsedFilePath = path__namespace.relative(__dirname, `.${filePath}`).replace(/\\/g, '/');
54
+ utils_messages.logMessage(logger, [
55
+ `Please pay attention! Found deprecated icons in file: `,
56
+ parsedFilePath,
57
+ foundIcons.map(({ replace, replaceWith }) => `\t${replace} -> \t${replaceWith}`).join('\n')
58
+ ]);
59
+ }
60
+ }
61
+ return newContent;
62
+ };
63
+ // Update styles, templates & components
64
+ targetDir.visit((filePath, entry) => {
65
+ let initialContent;
66
+ // if project property not provided, skip files in node_modules & dist
67
+ if (filePath.includes('node_modules') || filePath.includes('dist')) {
68
+ return;
69
+ }
70
+ if (filePath.endsWith('.html') || filePath.endsWith('.ts') || filePath.endsWith(stylesExt)) {
71
+ initialContent = entry?.content.toString();
72
+ let newContent = initialContent;
73
+ if (newContent) {
74
+ migrations_deprecatedIcons_data.iconClassReplacements.forEach(({ replace, replaceWith }) => {
75
+ newContent = newContent.replace(new RegExp(replace, 'g'), replaceWith);
76
+ });
77
+ newContent = handleDeprecatedIcons(newContent, filePath);
78
+ if (initialContent !== newContent) {
79
+ tree.overwrite(filePath, newContent || '');
80
+ }
81
+ }
82
+ }
83
+ });
84
+ // check if icon styles from new scope should be included in styles file
85
+ targetDir.visit((filePath, entry) => {
86
+ if (filePath.endsWith(stylesExt) && !entry?.content.toString()?.includes(iconsFontImportRule)) {
87
+ const parsedFilePath = path__namespace.relative(__dirname, `.${filePath}`).replace(/\\/g, '/');
88
+ utils_messages.logMessage(logger, [
89
+ parsedFilePath,
90
+ `Provide \`${iconsFontImportRule}\` to support icon styles from new scope`
91
+ ]);
92
+ }
93
+ });
94
+ };
95
+ }
96
+
97
+ exports.default = deprecatedIcons;
@@ -2,10 +2,10 @@
2
2
 
3
3
  Object.defineProperty(exports, '__esModule', { value: true });
4
4
 
5
- var chalk = require('chalk');
6
5
  var path = require('path');
7
- var utils_packageConfig = require('../utils/package-config.js');
8
- var newIconsPack_data = require('./data.js');
6
+ var utils_messages = require('../../utils/messages.js');
7
+ var utils_packageConfig = require('../../utils/package-config.js');
8
+ var migrations_newIconsPack_data = require('./data.js');
9
9
  require('@angular-devkit/schematics');
10
10
  require('@schematics/angular/utility');
11
11
 
@@ -28,12 +28,9 @@ function _interopNamespaceDefault(e) {
28
28
 
29
29
  var path__namespace = /*#__PURE__*/_interopNamespaceDefault(path);
30
30
 
31
- const { italic, blue, bold } = chalk;
32
- const data = newIconsPack_data.newIconsPackData;
31
+ const data = migrations_newIconsPack_data.newIconsPackData;
33
32
  function newIconsPack(options) {
34
33
  let targetDir;
35
- const breakingIconsVersionRegExp = /^\^|\~?9\.1\.0/;
36
- const pkg = '@koobiq/icons';
37
34
  return async (tree, context) => {
38
35
  const { project, fix, stylesExt } = options;
39
36
  try {
@@ -44,7 +41,7 @@ function newIconsPack(options) {
44
41
  targetDir = tree;
45
42
  }
46
43
  const { logger } = context;
47
- const handleDeprecatedIcons = (newContent, path) => {
44
+ const handleDeprecatedIcons = (newContent, filePath) => {
48
45
  if (fix) {
49
46
  data.forEach(({ replace, replaceWith }) => {
50
47
  newContent = newContent.replace(new RegExp(`kbq-${replace}`, 'g'), `kbq-${replaceWith}`);
@@ -53,32 +50,27 @@ function newIconsPack(options) {
53
50
  else {
54
51
  const foundIcons = data.filter(({ replace }) => newContent.indexOf(replace) !== -1);
55
52
  if (foundIcons.length) {
56
- showWarning(path, foundIcons, logger);
53
+ const parsedFilePath = path__namespace.relative(__dirname, `.${filePath}`).replace(/\\/g, '/');
54
+ utils_messages.logMessage(logger, [
55
+ `Please pay attention! Found deprecated icons in file: `,
56
+ parsedFilePath,
57
+ foundIcons.map(({ replace, replaceWith }) => `\t${replace} -> \t${replaceWith}`).join('\n')
58
+ ]);
57
59
  }
58
60
  }
59
61
  return newContent;
60
62
  };
61
- // Check if breaking version is used indeed
62
- if (tree.exists('package.json')) {
63
- const sourceText = tree.read('package.json').toString('utf-8');
64
- const json = JSON.parse(sourceText);
65
- const isIconsBreakingVersionUsed = ['devDependencies', 'dependencies', 'peerDependencies'].some((type) => json[type] && json[type][pkg] && breakingIconsVersionRegExp.test(json[type][pkg]));
66
- if (!isIconsBreakingVersionUsed) {
67
- logger.warn('Breaking version of icons is not used. Everything is OK.');
68
- return;
69
- }
70
- }
71
63
  // Update templates & components
72
64
  targetDir.visit((path, entry) => {
73
- // if project property not provided, provide node_modules to be changed
74
- if (path.includes('node_modules')) {
65
+ // if project property not provided, skip files in node_modules & dist
66
+ if (path.includes('node_modules') || path.includes('dist')) {
75
67
  return;
76
68
  }
77
69
  if (path.endsWith('.html') || path.endsWith('.ts') || path.endsWith('.md')) {
78
70
  const initialContent = entry?.content.toString();
79
71
  let newContent = initialContent;
80
72
  if (newContent) {
81
- newIconsPack_data.iconReplacements.forEach(({ replace, replaceWith }) => {
73
+ migrations_newIconsPack_data.iconReplacements.forEach(({ replace, replaceWith }) => {
82
74
  newContent = newContent.replace(new RegExp(replace, 'g'), replaceWith);
83
75
  });
84
76
  newContent = handleDeprecatedIcons(newContent, path);
@@ -109,12 +101,5 @@ function newIconsPack(options) {
109
101
  });
110
102
  };
111
103
  }
112
- function showWarning(filePath, foundIcons, logger) {
113
- logger.warn('-------------------------');
114
- logger.warn(`Please pay attention! Found deprecated icons in file: `);
115
- logger.info(`${bold(italic(blue(path__namespace.resolve(`.${filePath}`))))}`);
116
- logger.warn(foundIcons.map(({ replace, replaceWith }) => `\t${replace} -> \t${replaceWith}`).join('\n'));
117
- logger.warn('-------------------------');
118
- }
119
104
 
120
105
  exports.default = newIconsPack;
@@ -0,0 +1,25 @@
1
+ {
2
+ "$schema": "http://json-schema.org/schema",
3
+ "$id": "koobiq-components-new-icons-pack",
4
+ "title": "koobiq-components new-icons-pack schematic",
5
+ "type": "object",
6
+ "properties": {
7
+ "project": {
8
+ "type": "string",
9
+ "description": "Name of the project",
10
+ "$default": {
11
+ "$source": "projectName"
12
+ }
13
+ },
14
+ "fix": {
15
+ "type": "boolean",
16
+ "description": "Whether overwrite icons prefixes or simply inform in console",
17
+ "default": false
18
+ },
19
+ "stylesExt": {
20
+ "type": "string",
21
+ "description": "Use this option to specify styles extension preferred in your project",
22
+ "default": "scss"
23
+ }
24
+ }
25
+ }
@@ -5,6 +5,7 @@ Object.defineProperty(exports, '__esModule', { value: true });
5
5
  var schematics = require('@angular-devkit/schematics');
6
6
  var utility = require('@schematics/angular/utility');
7
7
  var utils_packageConfig = require('../utils/package-config.js');
8
+ require('../utils/messages.js');
8
9
 
9
10
  function noProject(project) {
10
11
  return `Unable to find project '${project}' in the workspace`;
@@ -41,8 +42,8 @@ function ngAdd(options) {
41
42
  }
42
43
  // Installing dependencies
43
44
  utils_packageConfig.addPackageToPackageJson(tree, '@angular/cdk', "^18.2.6");
44
- utils_packageConfig.addPackageToPackageJson(tree, '@koobiq/cdk', "^18.6.0");
45
- utils_packageConfig.addPackageToPackageJson(tree, '@koobiq/angular-luxon-adapter', "^18.6.0");
45
+ utils_packageConfig.addPackageToPackageJson(tree, '@koobiq/cdk', "^18.7.1");
46
+ utils_packageConfig.addPackageToPackageJson(tree, '@koobiq/angular-luxon-adapter', "^18.7.1");
46
47
  utils_packageConfig.addPackageToPackageJson(tree, '@koobiq/date-formatter', "^3.1.3");
47
48
  utils_packageConfig.addPackageToPackageJson(tree, '@koobiq/date-adapter', "^3.1.3");
48
49
  utils_packageConfig.addPackageToPackageJson(tree, '@koobiq/icons', "^9.1.0");
@@ -0,0 +1,13 @@
1
+ 'use strict';
2
+
3
+ function noProject(project) {
4
+ return `Unable to find project '${project}' in the workspace`;
5
+ }
6
+ const logMessage = (logger, content) => {
7
+ logger.warn('-------------------------');
8
+ logger.warn(content.join('\n'));
9
+ logger.warn('-------------------------');
10
+ };
11
+
12
+ exports.logMessage = logMessage;
13
+ exports.noProject = noProject;
@@ -2,10 +2,7 @@
2
2
 
3
3
  var schematics = require('@angular-devkit/schematics');
4
4
  var utility = require('@schematics/angular/utility');
5
-
6
- function noProject(project) {
7
- return `Unable to find project '${project}' in the workspace`;
8
- }
5
+ var utils_messages = require('./messages.js');
9
6
 
10
7
  /**
11
8
  * Sorts the keys of the given object.
@@ -54,7 +51,7 @@ async function setupOptions(project, tree) {
54
51
  const workspace = await utility.readWorkspace(tree);
55
52
  const projectWorkspace = workspace.projects.get(project);
56
53
  if (!projectWorkspace) {
57
- throw new schematics.SchematicsException(noProject(project));
54
+ throw new schematics.SchematicsException(utils_messages.noProject(project));
58
55
  }
59
56
  return projectWorkspace;
60
57
  }