djlint 1.9.0 → 1.9.3

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "djlint",
3
- "version": "1.9.0",
3
+ "version": "1.9.3",
4
4
  "description": "HTML Template Linter and Formatter",
5
5
  "main": "./bin/index.js",
6
6
  "directories": {
@@ -37,7 +37,7 @@
37
37
  },
38
38
  "scripts": {
39
39
  "format": "prettier --config .prettierrc \"{bin,docs}/**/*.{ts,css,less,scss,js,json,md,yaml,html}\" --write",
40
- "postinstall": "node ./bin/install.js",
40
+ "postinstall": "python3 -m pip install --upgrade djlint",
41
41
  "pre-commit": "lint-staged",
42
42
  "commit": "git add . && pre-commit run; npm run pre-commit && cz --no-verify",
43
43
  "test": "xo"
@@ -53,20 +53,20 @@
53
53
  "homepage": "https://djlint.com",
54
54
  "dependencies": {
55
55
  "python-shell": "^3.0.1",
56
- "yargs": "17.4.0"
56
+ "yargs": "17.5.1"
57
57
  },
58
58
  "devDependencies": {
59
59
  "@semantic-release/changelog": "6.0.1",
60
60
  "@semantic-release/commit-analyzer": "9.0.2",
61
61
  "@semantic-release/exec": "6.0.3",
62
62
  "@semantic-release/git": "10.0.1",
63
- "@semantic-release/github": "8.0.4",
63
+ "@semantic-release/github": "8.0.5",
64
64
  "@semantic-release/npm": "9.0.1",
65
65
  "@semantic-release/release-notes-generator": "10.0.3",
66
66
  "cz-conventional-changelog": "3.3.0",
67
- "lint-staged": "^13.0.3",
67
+ "lint-staged": "13.0.3",
68
68
  "semantic-release": "19.0.3",
69
- "xo": "^0.50.0"
69
+ "xo": "0.51.0"
70
70
  },
71
71
  "config": {
72
72
  "commitizen": {
package/bin/index.js DELETED
@@ -1,202 +0,0 @@
1
- #!/usr/bin/env node
2
-
3
- const process = require('process');
4
- const { PythonShell } = require('python-shell');
5
-
6
- PythonShell.defaultOptions = {
7
- mode: 'text',
8
- pythonOptions: ['-u'],
9
- env: { PYCHARM_HOSTED: 1 }, // Force color
10
- };
11
-
12
- function clean(output) {
13
- return output.replace(/python -m /g, '');
14
- }
15
-
16
- const yargs = require('yargs');
17
-
18
- const stdin = process.stdin;
19
-
20
- function getStdin() {
21
- // https://github.com/sindresorhus/get-stdin/pull/19/files
22
- let returnValue = '';
23
-
24
- return new Promise((resolve) => {
25
- if (stdin.isTTY) {
26
- resolve(returnValue);
27
- return;
28
- }
29
-
30
- const timeout = setTimeout(() => {
31
- resolve(returnValue);
32
- }, 100);
33
-
34
- stdin.unref();
35
- stdin.setEncoding('utf8');
36
-
37
- stdin.on('readable', () => {
38
- clearTimeout(timeout);
39
- stdin.ref();
40
-
41
- let chunk;
42
-
43
- while ((chunk = stdin.read())) {
44
- returnValue += chunk;
45
- }
46
- });
47
-
48
- stdin.on('end', () => {
49
- resolve(returnValue);
50
- });
51
- });
52
- }
53
-
54
- getStdin().then((string_) => {
55
- run(string_);
56
- });
57
-
58
- function run(stdin) {
59
- const options = yargs
60
- .scriptName('djlint')
61
- .usage(
62
- `Usage: $0 [OPTIONS] SRC ...
63
-
64
- djLint · lint and reformat HTML templates.`,
65
- )
66
- .option('e', {
67
- alias: 'extension',
68
- describe: 'File extension to check [default: html]',
69
- type: 'string',
70
- demandOption: false,
71
- })
72
- .option('h', {
73
- alias: 'help',
74
- describe: 'Show this message and exit.',
75
- type: 'boolean',
76
- demandOption: false,
77
- })
78
- .option('i', {
79
- alias: 'ignore',
80
- describe: 'Codes to ignore. ex: "H014,H017"',
81
- type: 'string',
82
- demandOption: false,
83
- })
84
- .option('reformat', {
85
- describe: 'Reformat the file(s).',
86
- type: 'boolean',
87
- demandOption: false,
88
- })
89
- .option('check', {
90
- describe: 'Check formatting on the file(s).',
91
- type: 'boolean',
92
- demandOption: false,
93
- })
94
- .option('indent', {
95
- describe: 'Indent spacing. [default: 4]',
96
- type: 'int',
97
- demandOption: false,
98
- })
99
- .option('quiet', {
100
- describe: 'Do not print diff when reformatting.',
101
- type: 'boolean',
102
- demandOption: false,
103
- })
104
- .option('warn', {
105
- describe: 'Return errors as warnings.',
106
- type: 'boolean',
107
- demandOption: false,
108
- })
109
- .option('profile', {
110
- describe:
111
- 'Enable defaults by template language. ops: django, jinja, nunjucks, handlebars, golang, angular, html [default: html]',
112
- type: 'string',
113
- demandOption: false,
114
- })
115
- .option('require-pragma', {
116
- describe:
117
- "Only format or lint files that starts with a comment with the text 'djlint:on'",
118
- type: 'boolean',
119
- demandOption: false,
120
- })
121
- .option('lint', {
122
- describe: 'Lint for common issues. [default option]',
123
- type: 'boolean',
124
- demandOption: false,
125
- })
126
- .option('use-gitignore', {
127
- describe: 'Use .gitignore file to extend excludes.',
128
- type: 'boolean',
129
- demandOption: false,
130
- })
131
- .option('format-css', {
132
- describe: 'Also format contents of <style> tags.',
133
- type: 'boolean',
134
- demandOption: false,
135
- })
136
- .option('format-js', {
137
- describe: 'Also format contents of <script> tags.',
138
- type: 'boolean',
139
- demandOption: false,
140
- }).argv;
141
-
142
- // Set flags
143
- const quiet = options.quiet ? '--quiet' : undefined;
144
- const help = options.h ? '--help' : undefined;
145
- const warn = options.warn ? '--warn' : undefined;
146
- const reformat = options.reformat ? '--reformat' : undefined;
147
- const check = options.check ? '--check' : undefined;
148
- const require_pragma = options['require-pragma']
149
- ? '--require-pragma'
150
- : undefined;
151
- const lint = options.lint ? '--lint' : undefined;
152
- const use_gitignore = options['use-gitignore']
153
- ? '--use-gitignore'
154
- : undefined;
155
- const format_css = options['format-css'] ? '--format-css' : undefined;
156
- const format_js = options['format-js'] ? '--format-js' : undefined;
157
- const has_stdin = stdin === '' ? options._[0] : '-';
158
-
159
- // Set variables
160
- const indent = options.indent ? '--indent=' + options.indent : undefined;
161
- const profile = options.profile ? '--profile=' + options.profile : undefined;
162
- const ignore = options.ignore ? '--ignore=' + options.ignore : undefined;
163
- const extension = options.e ? '-e=' + options.extension : undefined;
164
-
165
- const args = [
166
- has_stdin,
167
- warn,
168
- help,
169
- quiet,
170
- extension,
171
- reformat,
172
- check,
173
- require_pragma,
174
- lint,
175
- use_gitignore,
176
- indent,
177
- profile,
178
- ignore,
179
- format_css,
180
- format_js,
181
- ].filter((x) => {
182
- return x !== undefined;
183
- });
184
-
185
- const pyshell = new PythonShell('-m', { args: ['djlint', ...args] });
186
-
187
- if (stdin !== '') {
188
- pyshell.send(stdin);
189
- }
190
-
191
- pyshell.on('message', function (message) {
192
- console.log(clean(message));
193
- });
194
-
195
- pyshell.on('stderr', function (message) {
196
- console.log(clean(message));
197
- });
198
-
199
- pyshell.end(function (error, code) {
200
- process.exit(code);
201
- });
202
- }
package/bin/install.js DELETED
@@ -1,21 +0,0 @@
1
- const { PythonShell } = require('python-shell');
2
-
3
- PythonShell.defaultOptions = {};
4
- const options = {
5
- mode: 'text',
6
- args: ['pip', 'install', 'djlint'],
7
- pythonOptions: ['-u'],
8
- env: { PYCHARM_HOSTED: 1 },
9
- };
10
-
11
- try {
12
- PythonShell.getVersionSync();
13
-
14
- PythonShell.run('-m', options, function (error, results) {
15
- if (error) throw error;
16
- console.log(results.join('\n'));
17
- });
18
- } catch (e) {
19
- console.log(e.message);
20
- process.exit(1);
21
- }