-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Adds an --init script to start a boilerplate project.
- Loading branch information
Showing
13 changed files
with
129 additions
and
16 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,8 @@ | ||
{ | ||
"yaml.schemas": { | ||
"static/ld-workbench.schema.json": [ | ||
"configurations/*.yml", | ||
"static/example/*.yml" | ||
"pipelines/configurations/**/*.yml", | ||
"static/example/*.yml", | ||
], | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,73 @@ | ||
import fs from 'fs'; | ||
import { fileURLToPath } from 'url'; | ||
import * as path from 'path'; | ||
import glob from 'glob' | ||
|
||
export default function init(): void { | ||
const $dirname = path.dirname(fileURLToPath(import.meta.url)); | ||
if(fs.existsSync('pipelines')) { | ||
throw new Error('The --init script found an existing directory "pipelines". Make sure this directory does not exists before running this script.') | ||
} | ||
fs.mkdirSync('pipelines') | ||
fs.mkdirSync(path.join('pipelines', 'data')) | ||
fs.mkdirSync(path.join('pipelines', 'configurations')) | ||
fs.mkdirSync(path.join('pipelines', 'configurations', 'example')) | ||
const filepaths = glob.sync(path.join($dirname, '..', '..', 'static', 'example', '*')) | ||
for(const filepath of filepaths) { | ||
fs.copyFileSync(filepath, path.join('pipelines', 'configurations', 'example', path.basename(filepath))) | ||
} | ||
const yamlFile = path.join('pipelines', 'configurations', 'example', 'config.yml') | ||
const yaml = fs.readFileSync(yamlFile, 'utf-8') | ||
.replaceAll(/\/static\//g, '/pipelines/configurations/') | ||
fs.writeFileSync(yamlFile, yaml) | ||
|
||
const yamlSchemasSettings = { | ||
"yaml.schemas": { | ||
"node_modules/ldworkbench/static/ld-workbench.schema.json": [ | ||
"pipelines/configurations/**/*.yml", | ||
"static/example/*.yml", | ||
], | ||
} | ||
} | ||
|
||
const extensions = [ | ||
"dbaeumer.vscode-eslint", | ||
"stardog-union.vscode-langserver-sparql", | ||
"stardog-union.stardog-rdf-grammars", | ||
"MarkLindeman.turtle-vocab-autocomplete" | ||
] | ||
|
||
// setting up VSC/Git settings, if this fails, that's fine: | ||
try { | ||
if (!fs.existsSync('.gitignore')) { | ||
fs.writeFileSync('.gitignore', 'node_modules\n') | ||
} | ||
if (!fs.existsSync('.vscode')) fs.mkdirSync('.vscode') | ||
const settingsFile = path.join('.vscode', 'settings.json') | ||
const extensionsFile = path.join('.vscode', 'extensions.json') | ||
if (!fs.existsSync(settingsFile)) { | ||
fs.writeFileSync(settingsFile, JSON.stringify(yamlSchemasSettings, undefined, 2)) | ||
} else { | ||
const settings = JSON.parse(fs.readFileSync(settingsFile, 'utf-8')) | ||
if (!Object.hasOwn(settings, 'yaml.schemas')) { | ||
settings['yaml.schemas'] = yamlSchemasSettings['yaml.schemas'] | ||
} else { | ||
settings['yaml.schemas']["node_modules/ldworkbench/static/ld-workbench.schema.json"] = yamlSchemasSettings['yaml.schemas']["node_modules/ldworkbench/static/ld-workbench.schema.json"] | ||
} | ||
fs.writeFileSync(settingsFile, JSON.stringify(yamlSchemasSettings, undefined, 2)) | ||
} | ||
|
||
if (!fs.existsSync(extensionsFile)) { | ||
fs.writeFileSync(extensionsFile, JSON.stringify({recommendations: extensions}, undefined, 2)) | ||
} else { | ||
const settings = JSON.parse(fs.readFileSync(settingsFile, 'utf-8')) | ||
if (!Object.hasOwn(settings, 'recommendations')) { | ||
settings.recommendations = extensions | ||
} else { | ||
settings.recommendations = (settings.recommendations as string[]).concat(extensions) | ||
} | ||
fs.writeFileSync(settingsFile, JSON.stringify(settingsFile, undefined, 2)) | ||
} | ||
} catch(e) {} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,9 @@ | ||
import fs from 'fs'; | ||
|
||
import { fileURLToPath } from 'url'; | ||
import * as path from 'path'; | ||
export default function version(): string { | ||
const { version } = JSON.parse(fs.readFileSync('./package.json', 'utf-8')); | ||
const dirname = path.dirname(fileURLToPath(import.meta.url)); | ||
const filename = path.resolve(path.join(dirname, '..', '..', 'package.json')) | ||
const { version } = JSON.parse(fs.readFileSync(filename, 'utf-8')); | ||
return version; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters