detect-templating-language 3.0.5 → 3.0.11

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/LICENSE CHANGED
@@ -1,6 +1,6 @@
1
1
  MIT License
2
2
 
3
- Copyright (c) 2010-2021 Roy Revelt and other contributors
3
+ Copyright (c) 2010-2022 Roy Revelt and other contributors
4
4
 
5
5
  Permission is hereby granted, free of charge, to any person obtaining
6
6
  a copy of this software and associated documentation files (the
package/README.md CHANGED
@@ -26,18 +26,17 @@
26
26
 
27
27
  ## Install
28
28
 
29
- This package is ESM only: Node 12+ is needed to use it and it must be imported instead of required:
29
+ The latest version is **ESM only**: Node 12+ is needed to use it and it must be `import`ed instead of `require`d. If your project is not on ESM yet and you want to use `require`, use an older version of this program, `2.1.0`.
30
30
 
31
31
  ```bash
32
32
  npm i detect-templating-language
33
33
  ```
34
34
 
35
- If you need a legacy version which works with `require`, use version 2.1.0
36
-
37
35
  ## Quick Take
38
36
 
39
37
  ```js
40
38
  import { strict as assert } from "assert";
39
+
41
40
  import { detectLang } from "detect-templating-language";
42
41
 
43
42
  // detects Nunjucks
@@ -57,7 +56,7 @@ assert.deepEqual(
57
56
 
58
57
  ## Documentation
59
58
 
60
- Please [visit codsen.com](https://codsen.com/os/detect-templating-language/) for a full description of the API and examples.
59
+ Please [visit codsen.com](https://codsen.com/os/detect-templating-language/) for a full description of the API.
61
60
 
62
61
  ## Contributing
63
62
 
@@ -67,6 +66,6 @@ To report bugs or request features or assistance, [raise an issue](https://githu
67
66
 
68
67
  MIT License
69
68
 
70
- Copyright (c) 2010-2021 Roy Revelt and other contributors
69
+ Copyright (c) 2010-2022 Roy Revelt and other contributors
71
70
 
72
71
  <img src="https://codsen.com/images/png-codsen-ok.png" width="98" alt="ok" align="center"> <img src="https://codsen.com/images/png-codsen-1.png" width="148" alt="codsen" align="center"> <img src="https://codsen.com/images/png-codsen-star-small.png" width="32" alt="star" align="center">
@@ -1,40 +1,10 @@
1
1
  /**
2
2
  * @name detect-templating-language
3
3
  * @fileoverview Detects various templating languages present in string
4
- * @version 3.0.5
4
+ * @version 3.0.11
5
5
  * @author Roy Revelt, Codsen Ltd
6
6
  * @license MIT
7
7
  * {@link https://codsen.com/os/detect-templating-language/}
8
8
  */
9
9
 
10
- import { isJinjaNunjucksRegex } from 'regex-is-jinja-nunjucks';
11
- import { isJSP } from 'regex-is-jsp';
12
- import { isJinjaSpecific } from 'regex-jinja-specific';
13
-
14
- var version$1 = "3.0.5";
15
-
16
- const version = version$1;
17
- function detectLang(str) {
18
- let name = null;
19
- if (typeof str !== "string") {
20
- throw new TypeError(`detect-templating-language: [THROW_ID_01] Input must be string! It was given as ${JSON.stringify(str, null, 4)} (type ${typeof str}).`);
21
- }
22
- if (!str) {
23
- return {
24
- name
25
- };
26
- }
27
- if (isJinjaNunjucksRegex().test(str)) {
28
- name = "Nunjucks";
29
- if (isJinjaSpecific().test(str)) {
30
- name = "Jinja";
31
- }
32
- } else if (isJSP().test(str)) {
33
- name = "JSP";
34
- }
35
- return {
36
- name
37
- };
38
- }
39
-
40
- export { detectLang, version };
10
+ import{isJinjaNunjucksRegex as i}from"regex-is-jinja-nunjucks";import{isJSP as r}from"regex-is-jsp";import{isJinjaSpecific as p}from"regex-jinja-specific";var n="3.0.11";var d=n;function g(e){let t=null;if(typeof e!="string")throw new TypeError(`detect-templating-language: [THROW_ID_01] Input must be string! It was given as ${JSON.stringify(e,null,4)} (type ${typeof e}).`);return e?(i().test(e)?(t="Nunjucks",p().test(e)&&(t="Jinja")):r().test(e)&&(t="JSP"),{name:t}):{name:t}}export{g as detectLang,d as version};
@@ -1,18 +1,34 @@
1
1
  /**
2
2
  * @name detect-templating-language
3
3
  * @fileoverview Detects various templating languages present in string
4
- * @version 3.0.5
4
+ * @version 3.0.11
5
5
  * @author Roy Revelt, Codsen Ltd
6
6
  * @license MIT
7
7
  * {@link https://codsen.com/os/detect-templating-language/}
8
8
  */
9
9
 
10
- !function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports):"function"==typeof define&&define.amd?define(["exports"],t):t((e="undefined"!=typeof globalThis?globalThis:e||self).detectTemplatingLanguage={})}(this,(function(e){"use strict";
10
+ var detectTemplatingLanguage=(()=>{var i=Object.defineProperty;var o=Object.getOwnPropertyDescriptor;var l=Object.getOwnPropertyNames;var d=Object.prototype.hasOwnProperty;var g=e=>i(e,"__esModule",{value:!0});var m=(e,t)=>{for(var n in t)i(e,n,{get:t[n],enumerable:!0})},f=(e,t,n,r)=>{if(t&&typeof t=="object"||typeof t=="function")for(let s of l(t))!d.call(e,s)&&(n||s!=="default")&&i(e,s,{get:()=>t[s],enumerable:!(r=o(t,s))||r.enumerable});return e};var y=(e=>(t,n)=>e&&e.get(t)||(n=f(g({}),t,1),e&&e.set(t,n),n))(typeof WeakMap!="undefined"?new WeakMap:0);var h={};m(h,{detectLang:()=>v,version:()=>x});function a(){return/{%|{{|%}|}}/gi}function p(){return/<%|%>|<\s*jsp:|<\s*cms:|<\s*c:|\${\s*jsp/gi}function u(){return/(set\s*[\w]+\s*=\s*namespace\()|({{['"][\w]+['"]\s+if)|(['"]%x?[+0]?[.>^<]?\d+[\w%]['"]\|format\()/gi}var c="3.0.11";var x=c;function v(e){let t=null;if(typeof e!="string")throw new TypeError(`detect-templating-language: [THROW_ID_01] Input must be string! It was given as ${JSON.stringify(e,null,4)} (type ${typeof e}).`);return e?(a().test(e)?(t="Nunjucks",u().test(e)&&(t="Jinja")):p().test(e)&&(t="JSP"),{name:t}):{name:t}}return y(h);})();
11
11
  /**
12
12
  * @name regex-is-jinja-nunjucks
13
13
  * @fileoverview Regular expression for detecting Jinja or Nunjucks code
14
- * @version 3.0.5
14
+ * @version 3.0.11
15
15
  * @author Roy Revelt, Codsen Ltd
16
16
  * @license MIT
17
17
  * {@link https://codsen.com/os/regex-is-jinja-nunjucks/}
18
- */e.detectLang=function(e){let t=null;if("string"!=typeof e)throw new TypeError(`detect-templating-language: [THROW_ID_01] Input must be string! It was given as ${JSON.stringify(e,null,4)} (type ${typeof e}).`);return e?(/{%|{{|%}|}}/gi.test(e)?(t="Nunjucks",/(set\s*[\w]+\s*=\s*namespace\()|({{['"][\w]+['"]\s+if)|(['"]%x?[+0]?[.>^<]?\d+[\w%]['"]\|format\()/gi.test(e)&&(t="Jinja")):/<%|%>|<\s*jsp:|<\s*cms:|<\s*c:|\${\s*jsp/gi.test(e)&&(t="JSP"),{name:t}):{name:t}},e.version="3.0.5",Object.defineProperty(e,"__esModule",{value:!0})}));
18
+ */
19
+ /**
20
+ * @name regex-is-jsp
21
+ * @fileoverview Regular expression for detecting JSP (Java Server Pages) code
22
+ * @version 3.0.11
23
+ * @author Roy Revelt, Codsen Ltd
24
+ * @license MIT
25
+ * {@link https://codsen.com/os/regex-is-jsp/}
26
+ */
27
+ /**
28
+ * @name regex-jinja-specific
29
+ * @fileoverview Regular expression for detecting Python-specific Jinja code
30
+ * @version 3.0.11
31
+ * @author Roy Revelt, Codsen Ltd
32
+ * @license MIT
33
+ * {@link https://codsen.com/os/regex-jinja-specific/}
34
+ */
@@ -1,6 +1,7 @@
1
1
  // Quick Take
2
2
 
3
3
  import { strict as assert } from "assert";
4
+
4
5
  import { detectLang } from "../dist/detect-templating-language.esm.js";
5
6
 
6
7
  // detects Nunjucks
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "detect-templating-language",
3
- "version": "3.0.5",
3
+ "version": "3.0.11",
4
4
  "description": "Detects various templating languages present in string",
5
5
  "keywords": [
6
6
  "check",
@@ -29,96 +29,41 @@
29
29
  },
30
30
  "types": "types/index.d.ts",
31
31
  "scripts": {
32
- "build": "rollup -c",
33
- "ci_test": "npm run build && npm run format && tap --no-only --reporter=silent --output-file=testStats.md && npm run clean_cov",
34
- "clean_cov": "../../scripts/leaveCoverageTotalOnly.js",
35
- "clean_types": "../../scripts/cleanTypes.js",
36
- "dev": "rollup -c --dev",
37
- "devunittest": "npm run dev && tap --only -R 'base'",
38
- "esbuild": "node '../../scripts/esbuild.js'",
39
- "esbuild_dev": "cross-env MODE=dev node '../../scripts/esbuild.js'",
40
- "format": "npm run lect && npm run prettier && npm run lint",
41
- "lect": "lect",
42
- "lint": "../../node_modules/eslint/bin/eslint.js . --ext .js --ext .ts --fix --config \"../../.eslintrc.json\" --quiet",
43
- "perf": "node perf/check",
44
- "prettier": "../../node_modules/prettier/bin-prettier.js '*.{js,css,scss,vue,md,ts}' --write --loglevel silent",
45
- "republish": "npm publish || :",
46
- "tap": "tap",
47
- "pretest": "npm run build",
48
- "test": "npm run lint && npm run unittest && npm run test:examples && npm run clean_cov && npm run format",
49
- "test:examples": "../../scripts/test-examples.js && npm run lect && npm run prettier",
50
- "tsc": "tsc",
51
- "unittest": "tap --no-only --output-file=testStats.md --reporter=terse && tsc -p tsconfig.json --noEmit && npm run clean_cov && npm run perf"
32
+ "build": "node '../../ops/scripts/esbuild.js' && yarn run dts",
33
+ "dev": "DEV=true node '../../ops/scripts/esbuild.js' && yarn run dts",
34
+ "dts": "rollup -c && yarn run prettier 'types/index.d.ts' --write",
35
+ "examples": "node '../../ops/scripts/run-examples.js'",
36
+ "lect": "node '../../ops/lect/lect.js'",
37
+ "letspublish": "yarn publish || :",
38
+ "lint": "eslint . --fix",
39
+ "perf": "node perf/check.js",
40
+ "prepare": "echo 'ready'",
41
+ "prettier": "prettier",
42
+ "prettier:format": "prettier --write '**/*.{ts,tsx,md}' --no-error-on-unmatched-pattern",
43
+ "pretest": "yarn run lect && yarn run build",
44
+ "test": "c8 yarn run unit && yarn run examples && yarn run lint",
45
+ "unit": "uvu test"
52
46
  },
53
- "tap": {
54
- "check-coverage": false,
55
- "coverage-report": [
56
- "json-summary",
57
- "text"
58
- ],
59
- "node-arg": [
60
- "--no-warnings",
61
- "--experimental-loader",
62
- "@istanbuljs/esm-loader-hook"
47
+ "engines": {
48
+ "node": "^12.20.0 || ^14.13.1 || >=16.0.0"
49
+ },
50
+ "c8": {
51
+ "check-coverage": true,
52
+ "exclude": [
53
+ "**/test/**/*.*"
63
54
  ],
64
- "timeout": 0
55
+ "lines": 100
65
56
  },
66
57
  "lect": {
67
58
  "licence": {
68
59
  "extras": [
69
60
  ""
70
61
  ]
71
- },
72
- "req": "{ detectLang }",
73
- "various": {
74
- "devDependencies": []
75
62
  }
76
63
  },
77
64
  "dependencies": {
78
- "@babel/runtime": "^7.16.0",
79
- "regex-is-jinja-nunjucks": "^3.0.5",
80
- "regex-is-jsp": "^3.0.5",
81
- "regex-jinja-specific": "^3.0.5"
82
- },
83
- "devDependencies": {
84
- "@babel/cli": "^7.16.0",
85
- "@babel/core": "^7.16.0",
86
- "@babel/node": "^7.16.0",
87
- "@babel/plugin-external-helpers": "^7.16.0",
88
- "@babel/plugin-proposal-class-properties": "^7.16.0",
89
- "@babel/plugin-proposal-nullish-coalescing-operator": "^7.16.0",
90
- "@babel/plugin-proposal-object-rest-spread": "^7.16.0",
91
- "@babel/plugin-proposal-optional-chaining": "^7.16.0",
92
- "@babel/plugin-transform-runtime": "^7.16.0",
93
- "@babel/preset-env": "^7.16.0",
94
- "@babel/preset-typescript": "^7.16.0",
95
- "@babel/register": "^7.16.0",
96
- "@istanbuljs/esm-loader-hook": "^0.1.2",
97
- "@rollup/plugin-babel": "^5.3.0",
98
- "@rollup/plugin-commonjs": "^21.0.1",
99
- "@rollup/plugin-json": "^4.1.0",
100
- "@rollup/plugin-node-resolve": "^13.0.6",
101
- "@rollup/plugin-strip": "^2.1.0",
102
- "@rollup/plugin-typescript": "^8.3.0",
103
- "@types/node": "^16.11.6",
104
- "@types/tap": "^15.0.5",
105
- "@typescript-eslint/eslint-plugin": "^5.3.0",
106
- "@typescript-eslint/parser": "^5.3.0",
107
- "core-js": "^3.19.1",
108
- "cross-env": "^7.0.3",
109
- "eslint": "^8.2.0",
110
- "lect": "^0.18.5",
111
- "rollup": "^2.59.0",
112
- "rollup-plugin-ascii": "^0.0.3",
113
- "rollup-plugin-banner": "^0.2.1",
114
- "rollup-plugin-cleanup": "^3.2.1",
115
- "rollup-plugin-dts": "^4.0.1",
116
- "rollup-plugin-terser": "^7.0.2",
117
- "tap": "^15.0.10",
118
- "tslib": "^2.3.1",
119
- "typescript": "^4.4.4"
120
- },
121
- "engines": {
122
- "node": ">=12"
65
+ "regex-is-jinja-nunjucks": "^3.0.11",
66
+ "regex-is-jsp": "^3.0.11",
67
+ "regex-jinja-specific": "^3.0.11"
123
68
  }
124
69
  }
package/types/index.d.ts CHANGED
@@ -1,7 +1,7 @@
1
1
  declare const version: string;
2
2
  declare type Output = "Nunjucks" | "Jinja" | "JSP" | null;
3
3
  declare function detectLang(str: string): {
4
- name: Output;
4
+ name: Output;
5
5
  };
6
6
 
7
7
  export { detectLang, version };
package/examples/api.json DELETED
@@ -1 +0,0 @@
1
- {"_quickTake.js":{"title":"Quick Take","content":"import &#x7B; strict as assert &#x7D; from \"assert\";\nimport &#x7B; detectLang &#x7D; from \"detect-templating-language\";\n\n// detects Nunjucks\nassert.deepEqual(\n detectLang(`<div>&#x7B;% if something %&#x7D;x&#x7B;% else %&#x7D;y&#x7B;% endif %&#x7D;</div>`),\n &#x7B; name: \"Nunjucks\" &#x7D;\n);\n\n// detects JSP (Java Server Pages)\nassert.deepEqual(\n detectLang(\n `<div><c:set var=\"someList\" value=\"\\$&#x7B;jspProp.someList&#x7D;\" /></div>`\n ),\n &#x7B; name: \"JSP\" &#x7D;\n);"}}