mirror of
https://github.com/go-gitea/gitea
synced 2025-07-22 10:18:38 +00:00
Update CodeMirror to version 5.49.0 (#8381)
* Update CodeMirror to version 5.49.0 * Update CodeMirror versions in librejs and VERSIONS
This commit is contained in:
committed by
Lauris BH
parent
6fa14ac3c8
commit
1e9b330525
@@ -1,5 +1,5 @@
|
||||
// CodeMirror, copyright (c) by Marijn Haverbeke and others
|
||||
// Distributed under an MIT license: http://codemirror.net/LICENSE
|
||||
// Distributed under an MIT license: https://codemirror.net/LICENSE
|
||||
|
||||
(function(mod) {
|
||||
if (typeof exports == "object" && typeof module == "object") // CommonJS
|
||||
@@ -11,30 +11,64 @@
|
||||
})(function(CodeMirror) {
|
||||
"use strict";
|
||||
|
||||
var from = "from";
|
||||
var fromRegex = new RegExp("^(\\s*)\\b(" + from + ")\\b", "i");
|
||||
|
||||
var shells = ["run", "cmd", "entrypoint", "shell"];
|
||||
var shellsAsArrayRegex = new RegExp("^(\\s*)(" + shells.join('|') + ")(\\s+\\[)", "i");
|
||||
|
||||
var expose = "expose";
|
||||
var exposeRegex = new RegExp("^(\\s*)(" + expose + ")(\\s+)", "i");
|
||||
|
||||
var others = [
|
||||
"arg", "from", "maintainer", "label", "env",
|
||||
"add", "copy", "volume", "user",
|
||||
"workdir", "onbuild", "stopsignal", "healthcheck", "shell"
|
||||
];
|
||||
|
||||
// Collect all Dockerfile directives
|
||||
var instructions = ["from", "maintainer", "run", "cmd", "expose", "env",
|
||||
"add", "copy", "entrypoint", "volume", "user",
|
||||
"workdir", "onbuild"],
|
||||
var instructions = [from, expose].concat(shells).concat(others),
|
||||
instructionRegex = "(" + instructions.join('|') + ")",
|
||||
instructionOnlyLine = new RegExp(instructionRegex + "\\s*$", "i"),
|
||||
instructionWithArguments = new RegExp(instructionRegex + "(\\s+)", "i");
|
||||
instructionOnlyLine = new RegExp("^(\\s*)" + instructionRegex + "(\\s*)(#.*)?$", "i"),
|
||||
instructionWithArguments = new RegExp("^(\\s*)" + instructionRegex + "(\\s+)", "i");
|
||||
|
||||
CodeMirror.defineSimpleMode("dockerfile", {
|
||||
start: [
|
||||
// Block comment: This is a line starting with a comment
|
||||
{
|
||||
regex: /#.*$/,
|
||||
regex: /^\s*#.*$/,
|
||||
sol: true,
|
||||
token: "comment"
|
||||
},
|
||||
{
|
||||
regex: fromRegex,
|
||||
token: [null, "keyword"],
|
||||
sol: true,
|
||||
next: "from"
|
||||
},
|
||||
// Highlight an instruction without any arguments (for convenience)
|
||||
{
|
||||
regex: instructionOnlyLine,
|
||||
token: "variable-2"
|
||||
token: [null, "keyword", null, "error"],
|
||||
sol: true
|
||||
},
|
||||
{
|
||||
regex: shellsAsArrayRegex,
|
||||
token: [null, "keyword", null],
|
||||
sol: true,
|
||||
next: "array"
|
||||
},
|
||||
{
|
||||
regex: exposeRegex,
|
||||
token: [null, "keyword", null],
|
||||
sol: true,
|
||||
next: "expose"
|
||||
},
|
||||
// Highlight an instruction followed by arguments
|
||||
{
|
||||
regex: instructionWithArguments,
|
||||
token: ["variable-2", null],
|
||||
token: [null, "keyword", null],
|
||||
sol: true,
|
||||
next: "arguments"
|
||||
},
|
||||
{
|
||||
@@ -42,26 +76,21 @@
|
||||
token: null
|
||||
}
|
||||
],
|
||||
arguments: [
|
||||
from: [
|
||||
{
|
||||
regex: /\s*$/,
|
||||
token: null,
|
||||
next: "start"
|
||||
},
|
||||
{
|
||||
// Line comment without instruction arguments is an error
|
||||
regex: /#.*$/,
|
||||
token: "error",
|
||||
regex: /(\s*)(#.*)$/,
|
||||
token: [null, "error"],
|
||||
next: "start"
|
||||
},
|
||||
{
|
||||
regex: /[^#]+\\$/,
|
||||
token: null
|
||||
},
|
||||
{
|
||||
// Match everything except for the inline comment
|
||||
regex: /[^#]+/,
|
||||
token: null,
|
||||
next: "start"
|
||||
},
|
||||
{
|
||||
regex: /$/,
|
||||
token: null,
|
||||
regex: /(\s*\S+\s+)(as)/i,
|
||||
token: [null, "keyword"],
|
||||
next: "start"
|
||||
},
|
||||
// Fail safe return to start
|
||||
@@ -70,9 +99,112 @@
|
||||
next: "start"
|
||||
}
|
||||
],
|
||||
meta: {
|
||||
lineComment: "#"
|
||||
single: [
|
||||
{
|
||||
regex: /(?:[^\\']|\\.)/,
|
||||
token: "string"
|
||||
},
|
||||
{
|
||||
regex: /'/,
|
||||
token: "string",
|
||||
pop: true
|
||||
}
|
||||
],
|
||||
double: [
|
||||
{
|
||||
regex: /(?:[^\\"]|\\.)/,
|
||||
token: "string"
|
||||
},
|
||||
{
|
||||
regex: /"/,
|
||||
token: "string",
|
||||
pop: true
|
||||
}
|
||||
],
|
||||
array: [
|
||||
{
|
||||
regex: /\]/,
|
||||
token: null,
|
||||
next: "start"
|
||||
},
|
||||
{
|
||||
regex: /"(?:[^\\"]|\\.)*"?/,
|
||||
token: "string"
|
||||
}
|
||||
],
|
||||
expose: [
|
||||
{
|
||||
regex: /\d+$/,
|
||||
token: "number",
|
||||
next: "start"
|
||||
},
|
||||
{
|
||||
regex: /[^\d]+$/,
|
||||
token: null,
|
||||
next: "start"
|
||||
},
|
||||
{
|
||||
regex: /\d+/,
|
||||
token: "number"
|
||||
},
|
||||
{
|
||||
regex: /[^\d]+/,
|
||||
token: null
|
||||
},
|
||||
// Fail safe return to start
|
||||
{
|
||||
token: null,
|
||||
next: "start"
|
||||
}
|
||||
],
|
||||
arguments: [
|
||||
{
|
||||
regex: /^\s*#.*$/,
|
||||
sol: true,
|
||||
token: "comment"
|
||||
},
|
||||
{
|
||||
regex: /"(?:[^\\"]|\\.)*"?$/,
|
||||
token: "string",
|
||||
next: "start"
|
||||
},
|
||||
{
|
||||
regex: /"/,
|
||||
token: "string",
|
||||
push: "double"
|
||||
},
|
||||
{
|
||||
regex: /'(?:[^\\']|\\.)*'?$/,
|
||||
token: "string",
|
||||
next: "start"
|
||||
},
|
||||
{
|
||||
regex: /'/,
|
||||
token: "string",
|
||||
push: "single"
|
||||
},
|
||||
{
|
||||
regex: /[^#"']+[\\`]$/,
|
||||
token: null
|
||||
},
|
||||
{
|
||||
regex: /[^#"']+$/,
|
||||
token: null,
|
||||
next: "start"
|
||||
},
|
||||
{
|
||||
regex: /[^#"']+/,
|
||||
token: null
|
||||
},
|
||||
// Fail safe return to start
|
||||
{
|
||||
token: null,
|
||||
next: "start"
|
||||
}
|
||||
],
|
||||
meta: {
|
||||
lineComment: "#"
|
||||
}
|
||||
});
|
||||
|
||||
CodeMirror.defineMIME("text/x-dockerfile", "dockerfile");
|
||||
|
@@ -8,9 +8,9 @@
|
||||
<script src="../../lib/codemirror.js"></script>
|
||||
<script src="../../addon/mode/simple.js"></script>
|
||||
<script src="dockerfile.js"></script>
|
||||
<style type="text/css">.CodeMirror {border-top: 1px solid black; border-bottom: 1px solid black;}</style>
|
||||
<style>.CodeMirror {border-top: 1px solid black; border-bottom: 1px solid black;}</style>
|
||||
<div id=nav>
|
||||
<a href="http://codemirror.net"><h1>CodeMirror</h1><img id=logo src="../../doc/logo.png"></a>
|
||||
<a href="https://codemirror.net"><h1>CodeMirror</h1><img id=logo src="../../doc/logo.png"></a>
|
||||
|
||||
<ul>
|
||||
<li><a href="../../index.html">Home</a>
|
||||
|
128
public/vendor/plugins/codemirror/mode/dockerfile/test.js
vendored
Normal file
128
public/vendor/plugins/codemirror/mode/dockerfile/test.js
vendored
Normal file
@@ -0,0 +1,128 @@
|
||||
// CodeMirror, copyright (c) by Marijn Haverbeke and others
|
||||
// Distributed under an MIT license: https://codemirror.net/LICENSE
|
||||
|
||||
(function() {
|
||||
var mode = CodeMirror.getMode({indentUnit: 2}, "text/x-dockerfile");
|
||||
function MT(name) { test.mode(name, mode, Array.prototype.slice.call(arguments, 1)); }
|
||||
|
||||
MT("simple_nodejs_dockerfile",
|
||||
"[keyword FROM] node:carbon",
|
||||
"[comment # Create app directory]",
|
||||
"[keyword WORKDIR] /usr/src/app",
|
||||
"[comment # Install app dependencies]",
|
||||
"[comment # A wildcard is used to ensure both package.json AND package-lock.json are copied]",
|
||||
"[comment # where available (npm@5+)]",
|
||||
"[keyword COPY] package*.json ./",
|
||||
"[keyword RUN] npm install",
|
||||
"[keyword COPY] . .",
|
||||
"[keyword EXPOSE] [number 8080] [number 3000]",
|
||||
"[keyword ENV] NODE_ENV development",
|
||||
"[keyword CMD] [[ [string \"npm\"], [string \"start\"] ]]");
|
||||
|
||||
// Ideally the last space should not be highlighted.
|
||||
MT("instruction_without_args_1",
|
||||
"[keyword CMD] ");
|
||||
|
||||
MT("instruction_without_args_2",
|
||||
"[comment # An instruction without args...]",
|
||||
"[keyword ARG] [error #...is an error]");
|
||||
|
||||
MT("multiline",
|
||||
"[keyword RUN] apt-get update && apt-get install -y \\",
|
||||
" mercurial \\",
|
||||
" subversion \\",
|
||||
" && apt-get clean \\",
|
||||
" && rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/*");
|
||||
|
||||
MT("from_comment",
|
||||
" [keyword FROM] debian:stretch # I tend to use stable as that is more stable",
|
||||
" [keyword FROM] debian:stretch [keyword AS] stable # I am even more stable",
|
||||
" [keyword FROM] [error # this is an error]");
|
||||
|
||||
MT("from_as",
|
||||
"[keyword FROM] golang:1.9.2-alpine3.6 [keyword AS] build",
|
||||
"[keyword COPY] --from=build /bin/project /bin/project",
|
||||
"[keyword ENTRYPOINT] [[ [string \"/bin/project\"] ]]",
|
||||
"[keyword CMD] [[ [string \"--help\"] ]]");
|
||||
|
||||
MT("arg",
|
||||
"[keyword ARG] VERSION=latest",
|
||||
"[keyword FROM] busybox:$VERSION",
|
||||
"[keyword ARG] VERSION",
|
||||
"[keyword RUN] echo $VERSION > image_version");
|
||||
|
||||
MT("label",
|
||||
"[keyword LABEL] com.example.label-with-value=[string \"foo\"]");
|
||||
|
||||
MT("label_multiline",
|
||||
"[keyword LABEL] description=[string \"This text illustrates ]\\",
|
||||
"[string that label-values can span multiple lines.\"]");
|
||||
|
||||
MT("maintainer",
|
||||
"[keyword MAINTAINER] Foo Bar [string \"foo@bar.com\"] ",
|
||||
"[keyword MAINTAINER] Bar Baz <bar@baz.com>");
|
||||
|
||||
MT("env",
|
||||
"[keyword ENV] BUNDLE_PATH=[string \"$GEM_HOME\"] \\",
|
||||
" BUNDLE_APP_CONFIG=[string \"$GEM_HOME\"]");
|
||||
|
||||
MT("verify_keyword",
|
||||
"[keyword RUN] add-apt-repository ppa:chris-lea/node.js");
|
||||
|
||||
MT("scripts",
|
||||
"[comment # Set an entrypoint, to automatically install node modules]",
|
||||
"[keyword ENTRYPOINT] [[ [string \"/bin/bash\"], [string \"-c\"], [string \"if [[ ! -d node_modules ]]; then npm install; fi; exec \\\"${@:0}\\\";\"] ]]",
|
||||
"[keyword CMD] npm start",
|
||||
"[keyword RUN] npm run build && \\",
|
||||
"[comment # a comment between the shell commands]",
|
||||
" npm run test");
|
||||
|
||||
MT("strings_single",
|
||||
"[keyword FROM] buildpack-deps:stretch",
|
||||
"[keyword RUN] { \\",
|
||||
" echo [string 'install: --no-document']; \\",
|
||||
" echo [string 'update: --no-document']; \\",
|
||||
" } >> /usr/local/etc/gemrc");
|
||||
|
||||
MT("strings_single_multiline",
|
||||
"[keyword RUN] set -ex \\",
|
||||
" \\",
|
||||
" && buildDeps=[string ' ]\\",
|
||||
"[string bison ]\\",
|
||||
"[string dpkg-dev ]\\",
|
||||
"[string libgdbm-dev ]\\",
|
||||
"[string ruby ]\\",
|
||||
"[string '] \\",
|
||||
" && apt-get update");
|
||||
|
||||
MT("strings_single_multiline_2",
|
||||
"[keyword RUN] echo [string 'say \\' ]\\",
|
||||
"[string it works'] ");
|
||||
|
||||
MT("strings_double",
|
||||
"[keyword RUN] apt-get install -y --no-install-recommends $buildDeps \\",
|
||||
" \\",
|
||||
" && wget -O ruby.tar.xz [string \"https://cache.ruby-lang.org/pub/ruby/${RUBY_MAJOR%-rc}/ruby-$RUBY_VERSION.tar.xz\"] \\",
|
||||
" && echo [string \"$RUBY_DOWNLOAD_SHA256 *ruby.tar.xz\"] | sha256sum -c - ");
|
||||
|
||||
MT("strings_double_multiline",
|
||||
"[keyword RUN] echo [string \"say \\\" ]\\",
|
||||
"[string it works\"] ");
|
||||
|
||||
MT("escape",
|
||||
"[comment # escape=`]",
|
||||
"[keyword FROM] microsoft/windowsservercore",
|
||||
"[keyword RUN] powershell.exe -Command `",
|
||||
" $ErrorActionPreference = [string 'Stop']; `",
|
||||
" wget https://www.python.org/ftp/python/3.5.1/python-3.5.1.exe -OutFile c:\python-3.5.1.exe ; `",
|
||||
" Start-Process c:\python-3.5.1.exe -ArgumentList [string '/quiet InstallAllUsers=1 PrependPath=1'] -Wait ; `",
|
||||
" Remove-Item c:\python-3.5.1.exe -Force)");
|
||||
|
||||
MT("escape_strings",
|
||||
"[comment # escape=`]",
|
||||
"[keyword FROM] python:3.6-windowsservercore [keyword AS] python",
|
||||
"[keyword RUN] $env:PATH = [string 'C:\\Python;C:\\Python\\Scripts;{0}'] -f $env:PATH ; `",
|
||||
// It should not consider \' as escaped.
|
||||
// " Set-ItemProperty -Path [string 'HKLM:\\SYSTEM\\CurrentControlSet\\Control\\Session Manager\\Environment\\'] -Name Path -Value $env:PATH ;");
|
||||
" Set-ItemProperty -Path [string 'HKLM:\\SYSTEM\\CurrentControlSet\\Control\\Session Manager\\Environment\\' -Name Path -Value $env:PATH ;]");
|
||||
})();
|
Reference in New Issue
Block a user