Skip to content

Commit 4682bbd

Browse files
chore: remove gulp update deps (#65)
* chore: remove gulp update deps * empty commit to retrigger checks --------- Co-authored-by: Daphne Yang <daphne.yang@salesforce.com>
1 parent 88b3b71 commit 4682bbd

File tree

8 files changed

+1500
-3776
lines changed

8 files changed

+1500
-3776
lines changed

grammars/apex.tmLanguage.cson

Lines changed: 1259 additions & 1259 deletions
Large diffs are not rendered by default.

gulpfile.js

Lines changed: 0 additions & 99 deletions
This file was deleted.

package.json

Lines changed: 15 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -31,16 +31,18 @@
3131
}
3232
],
3333
"scripts": {
34-
"build": "gulp",
35-
"compile": "node ./node_modules/typescript/bin/tsc -p .",
34+
"build:grammars": "node scripts/build-grammars.js",
35+
"build:atom": "node scripts/build-atom.js",
36+
"build:soql": "node scripts/build-soql.js",
37+
"build": "npm run build:grammars && npm run build:atom && npm run build:soql",
38+
"compile": "tsc -p .",
3639
"commit-init": "commitizen init cz-conventional-changelog --save-dev --save-exact --force",
3740
"commit": "git-cz",
38-
"watch": "node ./node_modules/typescript/bin/tsc -w -p .",
41+
"watch": "tsc -w -p .",
3942
"test:soql-tmgrammar": "vscode-tmgrammar-test -g \"./grammars/soql.tmLanguage\" \"./test/soql/*.soql\" ",
4043
"test:soql-tmgrammar-snapshots": "vscode-tmgrammar-snap -s source.soql -g \"./grammars/soql.tmLanguage\" \"./test/soql/snapshots/*.soql\" ",
41-
"test": "gulp test && yarn run test:soql-tmgrammar && yarn run test:soql-tmgrammar-snapshots",
42-
"prepare": "gulp",
43-
"build:default": "gulp default",
44+
"test": "npm run compile && mocha out/test/**/*.tests.js && npm run test:soql-tmgrammar && npm run test:soql-tmgrammar-snapshots",
45+
"prepare": "npm run build",
4446
"format": "prettier --config .prettierrc.json --write './**/*.{ts,js,json,md}'"
4547
},
4648
"files": [
@@ -55,23 +57,18 @@
5557
"@commitlint/cli": "^17",
5658
"@commitlint/config-conventional": "^17",
5759
"@types/chai": "4.3.4",
58-
"@types/gulp": "^4.0.10",
59-
"@types/mocha": "^10.0.1",
60+
"@types/mocha": "^10.0.10",
6061
"chai": "^4.3.7",
61-
"commitizen": "^4.2.5",
62+
"commitizen": "^4.3.1",
63+
"cson-parser": "^4.0.9",
6264
"cz-conventional-changelog": "^3.3.0",
63-
"gulp": "4.0.2",
64-
"gulp-json2cson": "^2.0.0",
65-
"gulp-mocha": "^8.0.0",
66-
"gulp-typescript": "^5.0.1",
67-
"gulp-yaml": "^2.0.4",
6865
"js-yaml": "^4.1.0",
6966
"mocha": "^10.1.0",
70-
"plist": "^3.0.6",
67+
"plist": "^3.1.0",
7168
"prettier": "^2.8.0",
7269
"typescript": "4.9.3",
73-
"vscode-textmate": "7.0.4",
74-
"vscode-tmgrammar-test": "^0.1.1"
70+
"vscode-textmate": "^9.2.0",
71+
"vscode-tmgrammar-test": "^0.1.3"
7572
},
7673
"husky": {
7774
"hooks": {
@@ -83,4 +80,4 @@
8380
"path": "./node_modules/cz-conventional-changelog"
8481
}
8582
}
86-
}
83+
}

scripts/build-atom.js

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
const fs = require('fs');
2+
const path = require('path');
3+
const js_yaml = require('js-yaml');
4+
const cson = require('cson-parser');
5+
6+
const inputGrammar = 'src/apex.tmLanguage.yml';
7+
const grammarsDirectory = 'grammars/';
8+
9+
function handleError(err) {
10+
console.error(err.toString());
11+
process.exit(-1);
12+
}
13+
14+
try {
15+
// Create grammars directory if it doesn't exist
16+
if (!fs.existsSync(grammarsDirectory)) {
17+
fs.mkdirSync(grammarsDirectory);
18+
}
19+
20+
// Read and parse YAML
21+
const text = fs.readFileSync(inputGrammar);
22+
const jsonData = js_yaml.load(text);
23+
24+
// Convert to CSON with pretty formatting - using default output
25+
const csonData = cson.stringify(jsonData, null, 2);
26+
27+
// Write the output file
28+
fs.writeFileSync(
29+
path.join(grammarsDirectory, 'apex.tmLanguage.cson'),
30+
csonData
31+
);
32+
console.log('Successfully built Atom grammar');
33+
} catch (err) {
34+
handleError(err);
35+
}

scripts/build-grammars.js

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
const fs = require('fs');
2+
const path = require('path');
3+
const js_yaml = require('js-yaml');
4+
const plist = require('plist');
5+
6+
const inputGrammar = 'src/apex.tmLanguage.yml';
7+
const grammarsDirectory = 'grammars/';
8+
9+
function handleError(err) {
10+
console.error(err.toString());
11+
process.exit(-1);
12+
}
13+
14+
try {
15+
// Create grammars directory if it doesn't exist
16+
if (!fs.existsSync(grammarsDirectory)) {
17+
fs.mkdirSync(grammarsDirectory);
18+
}
19+
20+
// Read and parse YAML
21+
const text = fs.readFileSync(inputGrammar);
22+
const jsonData = js_yaml.load(text);
23+
24+
// Convert to plist
25+
const plistData = plist.build(jsonData);
26+
27+
// Write the output file
28+
fs.writeFileSync(path.join(grammarsDirectory, 'apex.tmLanguage'), plistData);
29+
console.log('Successfully built TextMate grammar');
30+
} catch (err) {
31+
handleError(err);
32+
}

scripts/build-soql.js

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
const fs = require('fs');
2+
const path = require('path');
3+
const js_yaml = require('js-yaml');
4+
const plist = require('plist');
5+
6+
const inputGrammar = 'src/apex.tmLanguage.yml';
7+
const inputSoqlGrammarTemplate = 'src/soql.tmLanguage.template.yml';
8+
const grammarsDirectory = 'grammars/';
9+
10+
function handleError(err) {
11+
console.error(err.toString());
12+
process.exit(-1);
13+
}
14+
15+
try {
16+
// Create grammars directory if it doesn't exist
17+
if (!fs.existsSync(grammarsDirectory)) {
18+
fs.mkdirSync(grammarsDirectory);
19+
}
20+
21+
// Read and parse both grammars
22+
const soqlGrammar = js_yaml.load(fs.readFileSync(inputSoqlGrammarTemplate));
23+
const apexGrammar = js_yaml.load(fs.readFileSync(inputGrammar));
24+
25+
// Merge the repository of rules from Apex grammar
26+
soqlGrammar['repository'] = Object.assign(
27+
{},
28+
apexGrammar.repository,
29+
soqlGrammar['repository']
30+
);
31+
32+
// Remove the comments rule SOQL query expression
33+
const apexGrammarSoqlExpressionPatterns =
34+
apexGrammar['repository']['soql-query-expression']['patterns'];
35+
soqlGrammar['repository']['soql-query-expression']['patterns'] =
36+
apexGrammarSoqlExpressionPatterns.filter(
37+
(pattern) => pattern.include !== '#comment'
38+
);
39+
40+
// Convert to plist and write
41+
const plistData = plist.build(soqlGrammar);
42+
fs.writeFileSync(path.join(grammarsDirectory, 'soql.tmLanguage'), plistData);
43+
console.log('Successfully built SOQL grammar');
44+
} catch (err) {
45+
handleError(err);
46+
}

test/utils/tokenize.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
* See LICENSE in the project root for license information.
55
*--------------------------------------------------------------------------------------------*/
66

7-
import { INITIAL, StackElement } from 'vscode-textmate';
7+
import { INITIAL, StateStack } from 'vscode-textmate';
88
import { TMRegistry } from './registry';
99

1010
const registry = new TMRegistry();
@@ -23,7 +23,7 @@ export async function tokenize(
2323
}
2424

2525
let tokens: Token[] = [];
26-
let previousStack: StackElement = INITIAL;
26+
let previousStack: StateStack = INITIAL;
2727
const grammar = await registry.loadGrammar('apex');
2828

2929
for (let lineIndex = 0; lineIndex < input.lines.length; lineIndex++) {

0 commit comments

Comments
 (0)