piral-cli 1.1.0-beta.5787 → 1.1.0-beta.5795

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.
@@ -1134,9 +1134,9 @@ var require_has_flag = __commonJS({
1134
1134
  }
1135
1135
  });
1136
1136
 
1137
- // ../../../node_modules/supports-color/index.js
1137
+ // ../../../node_modules/chalk/node_modules/supports-color/index.js
1138
1138
  var require_supports_color = __commonJS({
1139
- "../../../node_modules/supports-color/index.js"(exports, module2) {
1139
+ "../../../node_modules/chalk/node_modules/supports-color/index.js"(exports, module2) {
1140
1140
  "use strict";
1141
1141
  var os = require("os");
1142
1142
  var tty = require("tty");
@@ -58907,6 +58907,120 @@ var require_browser = __commonJS({
58907
58907
  }
58908
58908
  });
58909
58909
 
58910
+ // ../../../node_modules/supports-color/index.js
58911
+ var require_supports_color2 = __commonJS({
58912
+ "../../../node_modules/supports-color/index.js"(exports, module2) {
58913
+ "use strict";
58914
+ var os = require("os");
58915
+ var tty = require("tty");
58916
+ var hasFlag = require_has_flag();
58917
+ var { env } = process;
58918
+ var flagForceColor;
58919
+ if (hasFlag("no-color") || hasFlag("no-colors") || hasFlag("color=false") || hasFlag("color=never")) {
58920
+ flagForceColor = 0;
58921
+ } else if (hasFlag("color") || hasFlag("colors") || hasFlag("color=true") || hasFlag("color=always")) {
58922
+ flagForceColor = 1;
58923
+ }
58924
+ function envForceColor() {
58925
+ if ("FORCE_COLOR" in env) {
58926
+ if (env.FORCE_COLOR === "true") {
58927
+ return 1;
58928
+ }
58929
+ if (env.FORCE_COLOR === "false") {
58930
+ return 0;
58931
+ }
58932
+ return env.FORCE_COLOR.length === 0 ? 1 : Math.min(Number.parseInt(env.FORCE_COLOR, 10), 3);
58933
+ }
58934
+ }
58935
+ function translateLevel(level) {
58936
+ if (level === 0) {
58937
+ return false;
58938
+ }
58939
+ return {
58940
+ level,
58941
+ hasBasic: true,
58942
+ has256: level >= 2,
58943
+ has16m: level >= 3
58944
+ };
58945
+ }
58946
+ function supportsColor(haveStream, { streamIsTTY, sniffFlags = true } = {}) {
58947
+ const noFlagForceColor = envForceColor();
58948
+ if (noFlagForceColor !== void 0) {
58949
+ flagForceColor = noFlagForceColor;
58950
+ }
58951
+ const forceColor = sniffFlags ? flagForceColor : noFlagForceColor;
58952
+ if (forceColor === 0) {
58953
+ return 0;
58954
+ }
58955
+ if (sniffFlags) {
58956
+ if (hasFlag("color=16m") || hasFlag("color=full") || hasFlag("color=truecolor")) {
58957
+ return 3;
58958
+ }
58959
+ if (hasFlag("color=256")) {
58960
+ return 2;
58961
+ }
58962
+ }
58963
+ if (haveStream && !streamIsTTY && forceColor === void 0) {
58964
+ return 0;
58965
+ }
58966
+ const min = forceColor || 0;
58967
+ if (env.TERM === "dumb") {
58968
+ return min;
58969
+ }
58970
+ if (process.platform === "win32") {
58971
+ const osRelease = os.release().split(".");
58972
+ if (Number(osRelease[0]) >= 10 && Number(osRelease[2]) >= 10586) {
58973
+ return Number(osRelease[2]) >= 14931 ? 3 : 2;
58974
+ }
58975
+ return 1;
58976
+ }
58977
+ if ("CI" in env) {
58978
+ if (["TRAVIS", "CIRCLECI", "APPVEYOR", "GITLAB_CI", "GITHUB_ACTIONS", "BUILDKITE", "DRONE"].some((sign) => sign in env) || env.CI_NAME === "codeship") {
58979
+ return 1;
58980
+ }
58981
+ return min;
58982
+ }
58983
+ if ("TEAMCITY_VERSION" in env) {
58984
+ return /^(9\.(0*[1-9]\d*)\.|\d{2,}\.)/.test(env.TEAMCITY_VERSION) ? 1 : 0;
58985
+ }
58986
+ if (env.COLORTERM === "truecolor") {
58987
+ return 3;
58988
+ }
58989
+ if ("TERM_PROGRAM" in env) {
58990
+ const version = Number.parseInt((env.TERM_PROGRAM_VERSION || "").split(".")[0], 10);
58991
+ switch (env.TERM_PROGRAM) {
58992
+ case "iTerm.app":
58993
+ return version >= 3 ? 3 : 2;
58994
+ case "Apple_Terminal":
58995
+ return 2;
58996
+ }
58997
+ }
58998
+ if (/-256(color)?$/i.test(env.TERM)) {
58999
+ return 2;
59000
+ }
59001
+ if (/^screen|^xterm|^vt100|^vt220|^rxvt|color|ansi|cygwin|linux/i.test(env.TERM)) {
59002
+ return 1;
59003
+ }
59004
+ if ("COLORTERM" in env) {
59005
+ return 1;
59006
+ }
59007
+ return min;
59008
+ }
59009
+ function getSupportLevel(stream, options = {}) {
59010
+ const level = supportsColor(stream, {
59011
+ streamIsTTY: stream && stream.isTTY,
59012
+ ...options
59013
+ });
59014
+ return translateLevel(level);
59015
+ }
59016
+ module2.exports = {
59017
+ supportsColor: getSupportLevel,
59018
+ stdout: getSupportLevel({ isTTY: tty.isatty(1) }),
59019
+ stderr: getSupportLevel({ isTTY: tty.isatty(2) })
59020
+ };
59021
+ }
59022
+ });
59023
+
58910
59024
  // ../../../node_modules/debug/src/node.js
58911
59025
  var require_node2 = __commonJS({
58912
59026
  "../../../node_modules/debug/src/node.js"(exports, module2) {
@@ -58922,7 +59036,7 @@ var require_node2 = __commonJS({
58922
59036
  }, "Instance method `debug.destroy()` is deprecated and no longer does anything. It will be removed in the next major version of `debug`.");
58923
59037
  exports.colors = [6, 2, 3, 4, 5, 1];
58924
59038
  try {
58925
- const supportsColor = require_supports_color();
59039
+ const supportsColor = require_supports_color2();
58926
59040
  if (supportsColor && (supportsColor.stderr || supportsColor).level >= 2) {
58927
59041
  exports.colors = [
58928
59042
  20,
@@ -0,0 +1,16 @@
1
+ import { PiletRuleContext } from '../types';
2
+ export type Options = number;
3
+ /**
4
+ * Checks if a pilet might cause a CSS conflict. A score of 100 means that
5
+ * there is the least chance of a CSS conflict, while a score of 0 means that
6
+ * a CSS conflict is most likely.
7
+ *
8
+ * Negative values yield a warning if the CSS score is below the given number.
9
+ *
10
+ * Positive values yield an error if the CSS score is below the given number.
11
+ *
12
+ * A value of 0 turns this validation off.
13
+ *
14
+ * By default, a pilet's stylesheet having a CSS score of below 50 will result in a warning.
15
+ */
16
+ export default function (context: PiletRuleContext, options?: Options): Promise<void>;
@@ -0,0 +1,72 @@
1
+ "use strict";
2
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
3
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
4
+ return new (P || (P = Promise))(function (resolve, reject) {
5
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
6
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
7
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
8
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
9
+ });
10
+ };
11
+ Object.defineProperty(exports, "__esModule", { value: true });
12
+ const path_1 = require("path");
13
+ const css_conflict_inspector_1 = require("css-conflict-inspector");
14
+ const common_1 = require("../common");
15
+ function getPiletCssPaths(main, baseDir) {
16
+ return __awaiter(this, void 0, void 0, function* () {
17
+ const paths = [main, `dist/${main}`, `${main}/index.js`, `dist/${main}/index.js`, 'index.js', 'dist/index.js'];
18
+ for (const path of paths) {
19
+ const outDir = (0, path_1.dirname)((0, path_1.resolve)(baseDir, path));
20
+ const exists = yield (0, common_1.checkExists)(outDir);
21
+ if (exists) {
22
+ const files = yield (0, common_1.getFileNames)(outDir);
23
+ return files.filter((m) => m.endsWith('.css')).map((m) => (0, path_1.resolve)(outDir, m));
24
+ }
25
+ }
26
+ return [];
27
+ });
28
+ }
29
+ function getCssScore(dir, file) {
30
+ return __awaiter(this, void 0, void 0, function* () {
31
+ const content = yield (0, common_1.readText)(dir, file);
32
+ const result = (0, css_conflict_inspector_1.analyzeCss)(content);
33
+ return result.score;
34
+ });
35
+ }
36
+ /**
37
+ * Checks if a pilet might cause a CSS conflict. A score of 100 means that
38
+ * there is the least chance of a CSS conflict, while a score of 0 means that
39
+ * a CSS conflict is most likely.
40
+ *
41
+ * Negative values yield a warning if the CSS score is below the given number.
42
+ *
43
+ * Positive values yield an error if the CSS score is below the given number.
44
+ *
45
+ * A value of 0 turns this validation off.
46
+ *
47
+ * By default, a pilet's stylesheet having a CSS score of below 50 will result in a warning.
48
+ */
49
+ function default_1(context, options = -50) {
50
+ return __awaiter(this, void 0, void 0, function* () {
51
+ if (options !== 0 && typeof options === 'number') {
52
+ const threshold = Math.abs(options);
53
+ const { main } = context.piletPackage;
54
+ const paths = yield getPiletCssPaths(main, context.root);
55
+ for (const path of paths) {
56
+ const dir = (0, path_1.dirname)(path);
57
+ const file = (0, path_1.basename)(path);
58
+ const score = yield getCssScore(dir, file);
59
+ if (score < threshold) {
60
+ const notify = options > 0 ? context.error : context.warning;
61
+ notify(`
62
+ The CSS in "${file}" might lead to conflicts.
63
+ Minimum: ${threshold} points.
64
+ Received: ${score} points.
65
+ `);
66
+ }
67
+ }
68
+ }
69
+ });
70
+ }
71
+ exports.default = default_1;
72
+ //# sourceMappingURL=pilet-has-non-conflicting-css.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"pilet-has-non-conflicting-css.js","sourceRoot":"","sources":["../../src/rules/pilet-has-non-conflicting-css.ts"],"names":[],"mappings":";;;;;;;;;;;AAAA,+BAAkD;AAClD,mEAAoD;AACpD,sCAAgE;AAKhE,SAAe,gBAAgB,CAAC,IAAY,EAAE,OAAe;;QAC3D,MAAM,KAAK,GAAG,CAAC,IAAI,EAAE,QAAQ,IAAI,EAAE,EAAE,GAAG,IAAI,WAAW,EAAE,QAAQ,IAAI,WAAW,EAAE,UAAU,EAAE,eAAe,CAAC,CAAC;QAE/G,KAAK,MAAM,IAAI,IAAI,KAAK,EAAE;YACxB,MAAM,MAAM,GAAG,IAAA,cAAO,EAAC,IAAA,cAAO,EAAC,OAAO,EAAE,IAAI,CAAC,CAAC,CAAC;YAC/C,MAAM,MAAM,GAAG,MAAM,IAAA,oBAAW,EAAC,MAAM,CAAC,CAAC;YAEzC,IAAI,MAAM,EAAE;gBACV,MAAM,KAAK,GAAG,MAAM,IAAA,qBAAY,EAAC,MAAM,CAAC,CAAC;gBACzC,OAAO,KAAK,CAAC,MAAM,CA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7D,MAAM,CACJ;cACI,IAAI;aACL,SAAS;cACR,KAAK;CAClB,CACQ,CAAC;iBACH;aACF;SACF;IACH,CAAC;CAAA;AAvBD,4BAuBC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "piral-cli",
3
- "version": "1.1.0-beta.5787",
3
+ "version": "1.1.0-beta.5795",
4
4
  "description": "The standard CLI for creating and building a Piral instance or a Pilet.",
5
5
  "keywords": [
6
6
  "portal",
@@ -74,11 +74,12 @@
74
74
  "tar": "^4.4.8"
75
75
  },
76
76
  "dependencies": {
77
+ "css-conflict-inspector": "^0.2.0",
77
78
  "dets": "^0.13.0",
78
79
  "kras": "^0.15.4",
79
80
  "rimraf": "^3.0.0",
80
81
  "typescript": "^5.0.0",
81
82
  "yargs": "^15.0.0"
82
83
  },
83
- "gitHead": "c07aa61395a27f050cd41fcf1f77ef005340dc0e"
84
+ "gitHead": "da5f369c6bc3558a4a2013e121b5e622e39a0a54"
84
85
  }
@@ -0,0 +1,66 @@
1
+ import { basename, dirname, resolve } from 'path';
2
+ import { analyzeCss } from 'css-conflict-inspector';
3
+ import { checkExists, getFileNames, readText } from '../common';
4
+ import { PiletRuleContext } from '../types';
5
+
6
+ export type Options = number;
7
+
8
+ async function getPiletCssPaths(main: string, baseDir: string) {
9
+ const paths = [main, `dist/${main}`, `${main}/index.js`, `dist/${main}/index.js`, 'index.js', 'dist/index.js'];
10
+
11
+ for (const path of paths) {
12
+ const outDir = dirname(resolve(baseDir, path));
13
+ const exists = await checkExists(outDir);
14
+
15
+ if (exists) {
16
+ const files = await getFileNames(outDir);
17
+ return files.filter((m) => m.endsWith('.css')).map((m) => resolve(outDir, m));
18
+ }
19
+ }
20
+
21
+ return [];
22
+ }
23
+
24
+ async function getCssScore(dir: string, file: string) {
25
+ const content = await readText(dir, file);
26
+ const result = analyzeCss(content);
27
+ return result.score;
28
+ }
29
+
30
+ /**
31
+ * Checks if a pilet might cause a CSS conflict. A score of 100 means that
32
+ * there is the least chance of a CSS conflict, while a score of 0 means that
33
+ * a CSS conflict is most likely.
34
+ *
35
+ * Negative values yield a warning if the CSS score is below the given number.
36
+ *
37
+ * Positive values yield an error if the CSS score is below the given number.
38
+ *
39
+ * A value of 0 turns this validation off.
40
+ *
41
+ * By default, a pilet's stylesheet having a CSS score of below 50 will result in a warning.
42
+ */
43
+ export default async function (context: PiletRuleContext, options: Options = -50) {
44
+ if (options !== 0 && typeof options === 'number') {
45
+ const threshold = Math.abs(options);
46
+ const { main } = context.piletPackage;
47
+ const paths = await getPiletCssPaths(main, context.root);
48
+
49
+ for (const path of paths) {
50
+ const dir = dirname(path);
51
+ const file = basename(path);
52
+ const score = await getCssScore(dir, file);
53
+
54
+ if (score < threshold) {
55
+ const notify = options > 0 ? context.error : context.warning;
56
+ notify(
57
+ `
58
+ The CSS in "${file}" might lead to conflicts.
59
+ Minimum: ${threshold} points.
60
+ Received: ${score} points.
61
+ `,
62
+ );
63
+ }
64
+ }
65
+ }
66
+ }