punkweb-bb 0.2.3__py3-none-any.whl → 0.4.0__py3-none-any.whl
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.
- punkweb_bb/__pycache__/admin.cpython-311.pyc +0 -0
- punkweb_bb/__pycache__/admin_forms.cpython-311.pyc +0 -0
- punkweb_bb/__pycache__/bbcode.cpython-311.pyc +0 -0
- punkweb_bb/__pycache__/forms.cpython-311.pyc +0 -0
- punkweb_bb/__pycache__/middleware.cpython-311.pyc +0 -0
- punkweb_bb/__pycache__/mixins.cpython-311.pyc +0 -0
- punkweb_bb/__pycache__/models.cpython-311.pyc +0 -0
- punkweb_bb/__pycache__/pagination.cpython-311.pyc +0 -0
- punkweb_bb/__pycache__/parsers.cpython-311.pyc +0 -0
- punkweb_bb/__pycache__/response.cpython-311.pyc +0 -0
- punkweb_bb/__pycache__/settings.cpython-311.pyc +0 -0
- punkweb_bb/__pycache__/signals.cpython-311.pyc +0 -0
- punkweb_bb/__pycache__/tags.cpython-311.pyc +0 -0
- punkweb_bb/__pycache__/tests.cpython-311.pyc +0 -0
- punkweb_bb/__pycache__/urls.cpython-311.pyc +0 -0
- punkweb_bb/__pycache__/utils.cpython-311.pyc +0 -0
- punkweb_bb/__pycache__/views.cpython-311.pyc +0 -0
- punkweb_bb/__pycache__/widgets.cpython-311.pyc +0 -0
- punkweb_bb/admin.py +0 -5
- punkweb_bb/admin_forms.py +6 -5
- punkweb_bb/bbcode.py +155 -0
- punkweb_bb/forms.py +13 -5
- punkweb_bb/migrations/0005_alter_thread_options.py +24 -0
- punkweb_bb/migrations/0006_remove_boardprofile__signature_rendered_and_more.py +60 -0
- punkweb_bb/migrations/__pycache__/0005_alter_thread_options.cpython-311.pyc +0 -0
- punkweb_bb/migrations/__pycache__/0006_remove_boardprofile__signature_rendered_and_more.cpython-311.pyc +0 -0
- punkweb_bb/models.py +6 -6
- punkweb_bb/settings.py +1 -0
- punkweb_bb/static/punkweb_bb/css/defaults.css +2 -2
- punkweb_bb/static/punkweb_bb/css/punkweb-modal.css +2 -0
- punkweb_bb/static/punkweb_bb/css/punkweb.css +2 -2
- punkweb_bb/static/punkweb_bb/css/subcategory.css +4 -0
- punkweb_bb/static/punkweb_bb/css/thread.css +24 -0
- punkweb_bb/static/punkweb_bb/editor/bbcode-editor-content.css +4 -5
- punkweb_bb/static/punkweb_bb/editor/bbcode-editor.js +0 -5
- punkweb_bb/static/punkweb_bb/editor/markdown-editor.js +49 -0
- punkweb_bb/static/punkweb_bb/vendor/tiny-markdown-editor/.eslintrc.json +15 -0
- punkweb_bb/static/punkweb_bb/vendor/tiny-markdown-editor/.gitignore +108 -0
- punkweb_bb/static/punkweb_bb/vendor/tiny-markdown-editor/.prettierrc.json +1 -0
- punkweb_bb/static/punkweb_bb/vendor/tiny-markdown-editor/LICENSE +21 -0
- punkweb_bb/static/punkweb_bb/vendor/tiny-markdown-editor/README.md +240 -0
- punkweb_bb/static/punkweb_bb/vendor/tiny-markdown-editor/babel.config.json +14 -0
- punkweb_bb/static/punkweb_bb/vendor/tiny-markdown-editor/dist/blank.html +18 -0
- punkweb_bb/static/punkweb_bb/vendor/tiny-markdown-editor/dist/demo.html +126 -0
- punkweb_bb/static/punkweb_bb/vendor/tiny-markdown-editor/dist/tiny-mde.css +231 -0
- punkweb_bb/static/punkweb_bb/vendor/tiny-markdown-editor/dist/tiny-mde.js +3086 -0
- punkweb_bb/static/punkweb_bb/vendor/tiny-markdown-editor/dist/tiny-mde.min.css +1 -0
- punkweb_bb/static/punkweb_bb/vendor/tiny-markdown-editor/dist/tiny-mde.min.js +1 -0
- punkweb_bb/static/punkweb_bb/vendor/tiny-markdown-editor/dist/tiny-mde.tiny.js +1 -0
- punkweb_bb/static/punkweb_bb/vendor/tiny-markdown-editor/docs/_config.yml +1 -0
- punkweb_bb/static/punkweb_bb/vendor/tiny-markdown-editor/docs/_layouts/default.html +50 -0
- punkweb_bb/static/punkweb_bb/vendor/tiny-markdown-editor/docs/index.md +174 -0
- punkweb_bb/static/punkweb_bb/vendor/tiny-markdown-editor/globals.d.ts +172 -0
- punkweb_bb/static/punkweb_bb/vendor/tiny-markdown-editor/gulpfile.mjs +226 -0
- punkweb_bb/static/punkweb_bb/vendor/tiny-markdown-editor/jest/block.test.js +696 -0
- punkweb_bb/static/punkweb_bb/vendor/tiny-markdown-editor/jest/commandbar.test.js +84 -0
- punkweb_bb/static/punkweb_bb/vendor/tiny-markdown-editor/jest/inline.test.js +486 -0
- punkweb_bb/static/punkweb_bb/vendor/tiny-markdown-editor/jest/interaction.test.js +31 -0
- punkweb_bb/static/punkweb_bb/vendor/tiny-markdown-editor/jest/setup.test.js +164 -0
- punkweb_bb/static/punkweb_bb/vendor/tiny-markdown-editor/jest/util/config.js +2 -0
- punkweb_bb/static/punkweb_bb/vendor/tiny-markdown-editor/jest/util/server.js +9 -0
- punkweb_bb/static/punkweb_bb/vendor/tiny-markdown-editor/jest/util/setup.js +1 -0
- punkweb_bb/static/punkweb_bb/vendor/tiny-markdown-editor/jest/util/test-helpers.js +98 -0
- punkweb_bb/static/punkweb_bb/vendor/tiny-markdown-editor/jest-puppeteer.config.js +8 -0
- punkweb_bb/static/punkweb_bb/vendor/tiny-markdown-editor/jest.config.js +13 -0
- punkweb_bb/static/punkweb_bb/vendor/tiny-markdown-editor/package-lock.json +16295 -0
- punkweb_bb/static/punkweb_bb/vendor/tiny-markdown-editor/package.json +72 -0
- punkweb_bb/static/punkweb_bb/vendor/tiny-markdown-editor/src/TinyMDE.js +1926 -0
- punkweb_bb/static/punkweb_bb/vendor/tiny-markdown-editor/src/TinyMDECommandBar.js +256 -0
- punkweb_bb/static/punkweb_bb/vendor/tiny-markdown-editor/src/css/commandbar.css +72 -0
- punkweb_bb/static/punkweb_bb/vendor/tiny-markdown-editor/src/css/editor.css +157 -0
- punkweb_bb/static/punkweb_bb/vendor/tiny-markdown-editor/src/css/index.css +3 -0
- punkweb_bb/static/punkweb_bb/vendor/tiny-markdown-editor/src/grammar.js +300 -0
- punkweb_bb/static/punkweb_bb/vendor/tiny-markdown-editor/src/html/blank.html +18 -0
- punkweb_bb/static/punkweb_bb/vendor/tiny-markdown-editor/src/html/demo.html +126 -0
- punkweb_bb/static/punkweb_bb/vendor/tiny-markdown-editor/src/index.js +4 -0
- punkweb_bb/static/punkweb_bb/vendor/tiny-markdown-editor/src/svg/blockquote.svg +1 -0
- punkweb_bb/static/punkweb_bb/vendor/tiny-markdown-editor/src/svg/bold.svg +1 -0
- punkweb_bb/static/punkweb_bb/vendor/tiny-markdown-editor/src/svg/clear_formatting.svg +1 -0
- punkweb_bb/static/punkweb_bb/vendor/tiny-markdown-editor/src/svg/code.svg +1 -0
- punkweb_bb/static/punkweb_bb/vendor/tiny-markdown-editor/src/svg/h1.svg +1 -0
- punkweb_bb/static/punkweb_bb/vendor/tiny-markdown-editor/src/svg/h2.svg +1 -0
- punkweb_bb/static/punkweb_bb/vendor/tiny-markdown-editor/src/svg/hr.svg +1 -0
- punkweb_bb/static/punkweb_bb/vendor/tiny-markdown-editor/src/svg/image.svg +1 -0
- punkweb_bb/static/punkweb_bb/vendor/tiny-markdown-editor/src/svg/italic.svg +1 -0
- punkweb_bb/static/punkweb_bb/vendor/tiny-markdown-editor/src/svg/link.svg +1 -0
- punkweb_bb/static/punkweb_bb/vendor/tiny-markdown-editor/src/svg/ol.svg +1 -0
- punkweb_bb/static/punkweb_bb/vendor/tiny-markdown-editor/src/svg/strikethrough.svg +1 -0
- punkweb_bb/static/punkweb_bb/vendor/tiny-markdown-editor/src/svg/svg.js +17 -0
- punkweb_bb/static/punkweb_bb/vendor/tiny-markdown-editor/src/svg/ul.svg +1 -0
- punkweb_bb/static/punkweb_bb/vendor/tiny-markdown-editor/src/tiny.js +3 -0
- punkweb_bb/templates/punkweb_bb/base_delete_modal.html +13 -0
- punkweb_bb/templates/punkweb_bb/bbcode.html +2 -3
- punkweb_bb/templates/punkweb_bb/index.html +2 -2
- punkweb_bb/templates/punkweb_bb/partials/category_delete.html +4 -8
- punkweb_bb/templates/punkweb_bb/partials/post_delete.html +4 -8
- punkweb_bb/templates/punkweb_bb/partials/shout_delete.html +4 -8
- punkweb_bb/templates/punkweb_bb/partials/subcategory_delete.html +4 -8
- punkweb_bb/templates/punkweb_bb/partials/thread_delete.html +4 -8
- punkweb_bb/templates/punkweb_bb/partials/thread_move.html +24 -0
- punkweb_bb/templates/punkweb_bb/profile.html +2 -2
- punkweb_bb/templates/punkweb_bb/shoutbox/shout_list.html +2 -2
- punkweb_bb/templates/punkweb_bb/subcategory.html +1 -1
- punkweb_bb/templates/punkweb_bb/thread.html +24 -14
- punkweb_bb/templates/punkweb_bb/widgets/markdown-editor.html +4 -0
- punkweb_bb/templatetags/__pycache__/markdown.cpython-311.pyc +0 -0
- punkweb_bb/templatetags/__pycache__/render.cpython-311.pyc +0 -0
- punkweb_bb/templatetags/__pycache__/shoutbox_bbcode.cpython-311.pyc +0 -0
- punkweb_bb/templatetags/__pycache__/shoutbox_render.cpython-311.pyc +0 -0
- punkweb_bb/templatetags/render.py +35 -0
- punkweb_bb/tests.py +3 -3
- punkweb_bb/urls.py +1 -0
- punkweb_bb/utils.py +24 -10
- punkweb_bb/views.py +45 -23
- punkweb_bb/widgets.py +20 -0
- {punkweb_bb-0.2.3.dist-info → punkweb_bb-0.4.0.dist-info}/METADATA +58 -51
- {punkweb_bb-0.2.3.dist-info → punkweb_bb-0.4.0.dist-info}/RECORD +120 -53
- punkweb_bb/bbcode_tags.py +0 -167
- punkweb_bb/parsers.py +0 -70
- punkweb_bb/templatetags/shoutbox_bbcode.py +0 -14
- {punkweb_bb-0.2.3.dist-info → punkweb_bb-0.4.0.dist-info}/LICENSE +0 -0
- {punkweb_bb-0.2.3.dist-info → punkweb_bb-0.4.0.dist-info}/WHEEL +0 -0
- {punkweb_bb-0.2.3.dist-info → punkweb_bb-0.4.0.dist-info}/top_level.txt +0 -0
|
@@ -0,0 +1,172 @@
|
|
|
1
|
+
declare module "tiny-markdown-editor" {
|
|
2
|
+
type CursorPosition = {
|
|
3
|
+
col: number;
|
|
4
|
+
row: number;
|
|
5
|
+
node?: HTMLElement;
|
|
6
|
+
};
|
|
7
|
+
|
|
8
|
+
type CommonCommandName =
|
|
9
|
+
| "bold"
|
|
10
|
+
| "italic"
|
|
11
|
+
| "strikethrough"
|
|
12
|
+
| "code"
|
|
13
|
+
| "h1"
|
|
14
|
+
| "h2"
|
|
15
|
+
| "ul"
|
|
16
|
+
| "ol"
|
|
17
|
+
| "blockquote";
|
|
18
|
+
|
|
19
|
+
type CommandBarCommandName =
|
|
20
|
+
| CommonCommandName
|
|
21
|
+
| "hr"
|
|
22
|
+
| "insertLink"
|
|
23
|
+
| "insertImage";
|
|
24
|
+
|
|
25
|
+
type EditorCommandName = CommonCommandName | "h3" | "h4" | "h5" | "h6";
|
|
26
|
+
|
|
27
|
+
type ChangeEvent = {
|
|
28
|
+
content: string;
|
|
29
|
+
linesDirty: boolean[];
|
|
30
|
+
};
|
|
31
|
+
|
|
32
|
+
type SelectionEvent = {
|
|
33
|
+
focus: CursorPosition;
|
|
34
|
+
anchor: CursorPosition;
|
|
35
|
+
commandState: Record<EditorCommandName, boolean>;
|
|
36
|
+
};
|
|
37
|
+
|
|
38
|
+
type Listener<T extends "change" | "selection"> = (
|
|
39
|
+
event: T extends "change" ? ChangeEvent : SelectionEvent
|
|
40
|
+
) => void;
|
|
41
|
+
|
|
42
|
+
type EditorParams = {
|
|
43
|
+
element?: string | HTMLElement;
|
|
44
|
+
content?: string;
|
|
45
|
+
textarea?: string | HTMLElement;
|
|
46
|
+
};
|
|
47
|
+
|
|
48
|
+
export class Editor {
|
|
49
|
+
constructor(params: EditorParams?);
|
|
50
|
+
|
|
51
|
+
public getContent(): string;
|
|
52
|
+
|
|
53
|
+
public getSelection(getAnchor: boolean): CursorPosition | null;
|
|
54
|
+
|
|
55
|
+
public setSelection(
|
|
56
|
+
focus: CursorPosition,
|
|
57
|
+
anchor?: CursorPosition | null
|
|
58
|
+
): void;
|
|
59
|
+
|
|
60
|
+
public paste(
|
|
61
|
+
text: string,
|
|
62
|
+
anchor: CursorPosition,
|
|
63
|
+
focus: CursorPosition
|
|
64
|
+
): void;
|
|
65
|
+
|
|
66
|
+
public wrapSelection(
|
|
67
|
+
pre: string,
|
|
68
|
+
post: string,
|
|
69
|
+
anchor?: CursorPosition | null,
|
|
70
|
+
focus?: CursorPosition | null
|
|
71
|
+
): void;
|
|
72
|
+
|
|
73
|
+
public addEventListener<T extends "change" | "selection">(
|
|
74
|
+
type: T,
|
|
75
|
+
listener: Listener<T>
|
|
76
|
+
): void;
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
type ModifierKey =
|
|
80
|
+
| "Ctrl"
|
|
81
|
+
| "Cmd"
|
|
82
|
+
| "Alt"
|
|
83
|
+
| "Option"
|
|
84
|
+
| "Win"
|
|
85
|
+
| "Shift"
|
|
86
|
+
| "Mod"
|
|
87
|
+
| "Mod2";
|
|
88
|
+
type AlphanumericKey =
|
|
89
|
+
| "A"
|
|
90
|
+
| "B"
|
|
91
|
+
| "C"
|
|
92
|
+
| "D"
|
|
93
|
+
| "E"
|
|
94
|
+
| "F"
|
|
95
|
+
| "G"
|
|
96
|
+
| "H"
|
|
97
|
+
| "I"
|
|
98
|
+
| "J"
|
|
99
|
+
| "K"
|
|
100
|
+
| "L"
|
|
101
|
+
| "M"
|
|
102
|
+
| "N"
|
|
103
|
+
| "O"
|
|
104
|
+
| "P"
|
|
105
|
+
| "Q"
|
|
106
|
+
| "R"
|
|
107
|
+
| "S"
|
|
108
|
+
| "T"
|
|
109
|
+
| "U"
|
|
110
|
+
| "V"
|
|
111
|
+
| "W"
|
|
112
|
+
| "X"
|
|
113
|
+
| "Y"
|
|
114
|
+
| "Z"
|
|
115
|
+
| "a"
|
|
116
|
+
| "b"
|
|
117
|
+
| "c"
|
|
118
|
+
| "d"
|
|
119
|
+
| "e"
|
|
120
|
+
| "f"
|
|
121
|
+
| "g"
|
|
122
|
+
| "h"
|
|
123
|
+
| "i"
|
|
124
|
+
| "j"
|
|
125
|
+
| "k"
|
|
126
|
+
| "l"
|
|
127
|
+
| "m"
|
|
128
|
+
| "n"
|
|
129
|
+
| "o"
|
|
130
|
+
| "p"
|
|
131
|
+
| "q"
|
|
132
|
+
| "r"
|
|
133
|
+
| "s"
|
|
134
|
+
| "t"
|
|
135
|
+
| "u"
|
|
136
|
+
| "v"
|
|
137
|
+
| "w"
|
|
138
|
+
| "x"
|
|
139
|
+
| "y"
|
|
140
|
+
| "z"
|
|
141
|
+
| "0"
|
|
142
|
+
| "1"
|
|
143
|
+
| "2"
|
|
144
|
+
| "3"
|
|
145
|
+
| "4"
|
|
146
|
+
| "5"
|
|
147
|
+
| "6"
|
|
148
|
+
| "7"
|
|
149
|
+
| "8"
|
|
150
|
+
| "9";
|
|
151
|
+
type HotKey = AlphanumericKey | `${ModifierKey}-${HotKey}`;
|
|
152
|
+
|
|
153
|
+
type CommandBarCommand =
|
|
154
|
+
| CommandBarCommandName
|
|
155
|
+
| "|"
|
|
156
|
+
| {
|
|
157
|
+
name: CommandBarCommandName | string;
|
|
158
|
+
title?: string | undefined;
|
|
159
|
+
innerHTML?: string;
|
|
160
|
+
action?: EditorCommandName | ((editor: Editor) => void);
|
|
161
|
+
hotkey?: HotKey;
|
|
162
|
+
};
|
|
163
|
+
|
|
164
|
+
type CommandBarParams = {
|
|
165
|
+
element?: string | HTMLElement;
|
|
166
|
+
editor: Editor;
|
|
167
|
+
commands?: CommandBarCommand[];
|
|
168
|
+
};
|
|
169
|
+
export class CommandBar {
|
|
170
|
+
constructor(params: CommandBarParams);
|
|
171
|
+
}
|
|
172
|
+
}
|
|
@@ -0,0 +1,226 @@
|
|
|
1
|
+
import gulp from "gulp";
|
|
2
|
+
|
|
3
|
+
import size from "gulp-size";
|
|
4
|
+
import rename from "gulp-rename";
|
|
5
|
+
import source from "vinyl-source-stream";
|
|
6
|
+
import buffer from "vinyl-buffer";
|
|
7
|
+
|
|
8
|
+
import rollupStream from "@rollup/stream";
|
|
9
|
+
import { babel as rollupBabel } from "@rollup/plugin-babel";
|
|
10
|
+
import commonjs from "@rollup/plugin-commonjs";
|
|
11
|
+
import { eslint } from "rollup-plugin-eslint";
|
|
12
|
+
import { nodeResolve } from "@rollup/plugin-node-resolve";
|
|
13
|
+
import terser from "gulp-terser";
|
|
14
|
+
|
|
15
|
+
import gulpBabel from "gulp-babel";
|
|
16
|
+
|
|
17
|
+
import postcss from "gulp-postcss";
|
|
18
|
+
import autoprefixer from "autoprefixer";
|
|
19
|
+
import postcss_import from "postcss-import";
|
|
20
|
+
import cssnano from "cssnano";
|
|
21
|
+
|
|
22
|
+
import jestCLI from "jest-cli";
|
|
23
|
+
|
|
24
|
+
import { deleteAsync as del } from "del";
|
|
25
|
+
import fs from "fs";
|
|
26
|
+
import path from "path";
|
|
27
|
+
|
|
28
|
+
import util from "util";
|
|
29
|
+
import child_process from "node:child_process";
|
|
30
|
+
import readline from "node:readline/promises";
|
|
31
|
+
import "dotenv/config";
|
|
32
|
+
import process from "process";
|
|
33
|
+
|
|
34
|
+
import { Octokit } from "@octokit/rest";
|
|
35
|
+
|
|
36
|
+
const readfile = util.promisify(fs.readFile);
|
|
37
|
+
const writefile = util.promisify(fs.writeFile);
|
|
38
|
+
|
|
39
|
+
let cache;
|
|
40
|
+
|
|
41
|
+
const rollupConfig = (inputFile, sourcemaps = false) => {
|
|
42
|
+
return {
|
|
43
|
+
input: inputFile,
|
|
44
|
+
output: {
|
|
45
|
+
format: "umd",
|
|
46
|
+
name: "TinyMDE",
|
|
47
|
+
sourcemap: sourcemaps,
|
|
48
|
+
},
|
|
49
|
+
plugins: [
|
|
50
|
+
eslint({ throwOnError: true }),
|
|
51
|
+
rollupBabel({ babelHelpers: "bundled" }),
|
|
52
|
+
nodeResolve(),
|
|
53
|
+
commonjs(),
|
|
54
|
+
],
|
|
55
|
+
};
|
|
56
|
+
};
|
|
57
|
+
|
|
58
|
+
const clean = () => del(["./dist", "./lib"]);
|
|
59
|
+
|
|
60
|
+
const jest = () => jestCLI.run([]);
|
|
61
|
+
|
|
62
|
+
const jsMax = () =>
|
|
63
|
+
rollupStream({ ...rollupConfig("./src/index.js", true), cache })
|
|
64
|
+
.on("bundle", (bundle) => {
|
|
65
|
+
cache = bundle;
|
|
66
|
+
})
|
|
67
|
+
.pipe(source("tiny-mde.js"))
|
|
68
|
+
.pipe(buffer())
|
|
69
|
+
.pipe(size({ showFiles: true }))
|
|
70
|
+
.pipe(gulp.dest("./dist"))
|
|
71
|
+
.pipe(rename("tiny-mde.min.js"))
|
|
72
|
+
.pipe(terser())
|
|
73
|
+
.pipe(size({ showFiles: true }))
|
|
74
|
+
.pipe(gulp.dest("./dist"));
|
|
75
|
+
const jsTiny = () =>
|
|
76
|
+
rollupStream(rollupConfig("./src/tiny.js"))
|
|
77
|
+
.pipe(source("tiny-mde.tiny.js"))
|
|
78
|
+
.pipe(buffer())
|
|
79
|
+
.pipe(terser())
|
|
80
|
+
.pipe(gulp.dest("./dist"))
|
|
81
|
+
.pipe(size({ showFiles: true }));
|
|
82
|
+
|
|
83
|
+
const js = gulp.series(jsMax, jsTiny);
|
|
84
|
+
|
|
85
|
+
const transpile = () =>
|
|
86
|
+
gulp
|
|
87
|
+
.src("./src/**/*.js")
|
|
88
|
+
.pipe(gulpBabel({ plugins: ["@babel/plugin-transform-modules-commonjs"] }))
|
|
89
|
+
.pipe(gulp.dest("./lib"));
|
|
90
|
+
|
|
91
|
+
const html = () => gulp.src("./src/html/*.html").pipe(gulp.dest("./dist"));
|
|
92
|
+
|
|
93
|
+
const css = () =>
|
|
94
|
+
gulp
|
|
95
|
+
.src("./src/css/index.css")
|
|
96
|
+
.pipe(postcss([postcss_import(), autoprefixer()]))
|
|
97
|
+
.pipe(rename("tiny-mde.css"))
|
|
98
|
+
.pipe(gulp.dest("./dist"))
|
|
99
|
+
.pipe(postcss([cssnano()]))
|
|
100
|
+
.pipe(rename("tiny-mde.min.css"))
|
|
101
|
+
.pipe(gulp.dest("./dist"));
|
|
102
|
+
|
|
103
|
+
const watch = () => {
|
|
104
|
+
gulp.watch("./src/**/*.svg", svg);
|
|
105
|
+
gulp.watch("./src/**/*.js", jsMax);
|
|
106
|
+
gulp.watch("./src/**/*.css", css);
|
|
107
|
+
gulp.watch("./src/**/*.html", html);
|
|
108
|
+
};
|
|
109
|
+
|
|
110
|
+
const svg = () => {
|
|
111
|
+
const dirEntries = fs.readdirSync(path.join(".", "src", "svg"), {
|
|
112
|
+
withFileTypes: true,
|
|
113
|
+
});
|
|
114
|
+
let promises = [];
|
|
115
|
+
for (let entry of dirEntries) {
|
|
116
|
+
if (entry.isFile() && entry.name.match(/\.svg$/i)) {
|
|
117
|
+
let fn = entry.name;
|
|
118
|
+
promises.push(
|
|
119
|
+
readfile(path.join(".", "src", "svg", fn), { encoding: "utf8" }).then(
|
|
120
|
+
(buffer) => {
|
|
121
|
+
// console.log(entry.name + ': ' + buffer.toString().replace(/([`\$\\])/g, '\\$1'));
|
|
122
|
+
return `${fn.replace(/^(.*)\.svg$/i, "$1")}: \`${buffer
|
|
123
|
+
.toString()
|
|
124
|
+
.replace(/([`$\\])/g, "\\$1")}\``;
|
|
125
|
+
}
|
|
126
|
+
)
|
|
127
|
+
);
|
|
128
|
+
}
|
|
129
|
+
}
|
|
130
|
+
return Promise.all(promises).then((values) =>
|
|
131
|
+
writefile(
|
|
132
|
+
path.join(".", "src", "svg", "svg.js"),
|
|
133
|
+
`const svg = {\n ${values.join(",\n ")}\n};\n\nexport default svg;`,
|
|
134
|
+
{ encoding: "utf8" }
|
|
135
|
+
)
|
|
136
|
+
);
|
|
137
|
+
};
|
|
138
|
+
|
|
139
|
+
const execPromise = (command) => {
|
|
140
|
+
const cp = child_process.exec(command, { shell: "/bin/zsh" });
|
|
141
|
+
cp.stdout.on("data", (data) => {
|
|
142
|
+
console.log(data.toString());
|
|
143
|
+
});
|
|
144
|
+
cp.stderr.on("data", (data) => {
|
|
145
|
+
console.error(data.toString());
|
|
146
|
+
});
|
|
147
|
+
return new Promise((resolve, reject) => {
|
|
148
|
+
cp.on("exit", (code) => (code ? reject(code) : resolve()));
|
|
149
|
+
});
|
|
150
|
+
};
|
|
151
|
+
|
|
152
|
+
const bumpVersion = () => {
|
|
153
|
+
return execPromise("npm version patch");
|
|
154
|
+
};
|
|
155
|
+
|
|
156
|
+
const npmRelease = async () => {
|
|
157
|
+
const otp = await readline
|
|
158
|
+
.createInterface({
|
|
159
|
+
input: process.stdin,
|
|
160
|
+
output: process.stdout,
|
|
161
|
+
})
|
|
162
|
+
.question("Please enter a one-time password for NPM");
|
|
163
|
+
return execPromise(`npm publish --otp=${otp}`);
|
|
164
|
+
};
|
|
165
|
+
|
|
166
|
+
const gitCheckBranch = async () => {
|
|
167
|
+
return new Promise((resolve, reject) => {
|
|
168
|
+
child_process.exec("git branch --show-current", (err, stdout) => {
|
|
169
|
+
if (err) reject(err);
|
|
170
|
+
const branch = stdout.trim();
|
|
171
|
+
if (branch === "main") {
|
|
172
|
+
resolve();
|
|
173
|
+
} else {
|
|
174
|
+
reject(
|
|
175
|
+
`Releases can only be made from the main branch, current branch is ${branch}`
|
|
176
|
+
);
|
|
177
|
+
}
|
|
178
|
+
});
|
|
179
|
+
});
|
|
180
|
+
};
|
|
181
|
+
|
|
182
|
+
const gitPush = () => {
|
|
183
|
+
return execPromise("git push");
|
|
184
|
+
};
|
|
185
|
+
|
|
186
|
+
const ghRelease = async () => {
|
|
187
|
+
const { version } = JSON.parse(await readfile("package.json"));
|
|
188
|
+
|
|
189
|
+
const octokit = new Octokit({ auth: process.env.GITHUB_ACCESS_TOKEN });
|
|
190
|
+
return octokit.repos.createRelease({
|
|
191
|
+
owner: "jefago",
|
|
192
|
+
repo: "tiny-markdown-editor",
|
|
193
|
+
tag_name: `v${version}`, // The name of the tag
|
|
194
|
+
name: `v${version}`,
|
|
195
|
+
body: "",
|
|
196
|
+
draft: false,
|
|
197
|
+
prerelease: false,
|
|
198
|
+
});
|
|
199
|
+
};
|
|
200
|
+
|
|
201
|
+
const build = gulp.series(clean, svg, js, css, html);
|
|
202
|
+
|
|
203
|
+
const dev = gulp.series(clean, svg, jsMax, css, html, watch);
|
|
204
|
+
|
|
205
|
+
const test = gulp.series(build, jest);
|
|
206
|
+
|
|
207
|
+
const prepublish = gulp.series(build, jest, transpile);
|
|
208
|
+
|
|
209
|
+
const release = gulp.series(
|
|
210
|
+
gitCheckBranch,
|
|
211
|
+
prepublish,
|
|
212
|
+
npmRelease,
|
|
213
|
+
gitPush,
|
|
214
|
+
ghRelease
|
|
215
|
+
);
|
|
216
|
+
|
|
217
|
+
const releasePatch = gulp.series(gitCheckBranch, bumpVersion, release);
|
|
218
|
+
|
|
219
|
+
export { dev, test, svg, prepublish, releasePatch, release };
|
|
220
|
+
|
|
221
|
+
export default build;
|
|
222
|
+
// exports.default = build;
|
|
223
|
+
// exports.dev = dev;
|
|
224
|
+
// exports.test = test;
|
|
225
|
+
// exports.svg = svg;
|
|
226
|
+
// exports.prepublish = prepublish;
|