Skip to content
Snippets Groups Projects
Commit 93b82560 authored by RWTH App's avatar RWTH App
Browse files

New: Javascript-Template

parents
Branches Sprint/2022-01 dev master
No related tags found
No related merge requests found
Pipeline #635650 failed
# Dist folder
dist
publishDocsTempFolder
.vscode
package-lock.json
# Logs
logs
*.log
npm-debug.log*
yarn-debug.log*
yarn-error.log*
# Runtime data
pids
*.pid
*.seed
*.pid.lock
# Directory for instrumented libs generated by jscoverage/JSCover
lib-cov
# Coverage directory used by tools like istanbul
coverage
# nyc test coverage
.nyc_output
# Grunt intermediate storage (https://gruntjs.com/creating-plugins#storing-task-files)
.grunt
# Bower dependency directory (https://bower.io/)
bower_components
# node-waf configuration
.lock-wscript
# Compiled binary addons (https://nodejs.org/api/addons.html)
build/Release
# Dependency directories
node_modules/
jspm_packages/
# TypeScript v1 declaration files
# typings/
# Optional npm cache directory
.npm
# Optional eslint cache
.eslintcache
# Optional REPL history
.node_repl_history
# Output of 'npm pack'
*.tgz
# Yarn Integrity file
.yarn-integrity
# dotenv environment variables file
.env
# parcel-bundler cache (https://parceljs.org/)
.cache
# next.js build output
.next
# nuxt.js build output
.nuxt
# vuepress build output
.vuepress/dist
# Serverless directories
.serverless
# FuseBox cache
.fusebox/
stages:
- build
- test
- docs
- publish
- release
before_script:
- npm install
build:
stage: build
script:
- npm run build
except:
variables:
- $GITLAB_USER_ID == $GIT_BOT_USER_ID
test:
stage: test
script:
- npm test
except:
variables:
- $GITLAB_USER_ID == $GIT_BOT_USER_ID
docs:
stage: docs
script:
- .\publishDocs.ps1 $GITLAB_TOKEN
except:
variables:
- $GITLAB_USER_ID == $GIT_BOT_USER_ID
publish:
stage: publish
script:
- npm run build
- npx semantic-release
only:
- master
except:
variables:
- $GITLAB_USER_ID == $GIT_BOT_USER_ID
release:
stage: release
script:
- npm run build
artifacts:
paths:
- dist
only:
- tags
\ No newline at end of file
{
"plugins": [
["@semantic-release/commit-analyzer", {
"preset": "eslint"
}],
["@semantic-release/release-notes-generator", {
"preset": "eslint",
}],
["@semantic-release/gitlab", {
"preset": "eslint",
"gitlabUrl": "https://git.rwth-aachen.de"
}],
#Currently not supported
["@semantic-release/npm", {
"preset": "eslint",
"tarballDir": "dist",
"npmPublish": false
}],
["@semantic-release/git", {
"preset": "eslint",
"assets": ["package.json"],
"message": "Chore: ${nextRelease.version}\n\n${nextRelease.notes}"
}]
]
}
\ No newline at end of file
LICENSE 0 → 100644
MIT License
Copyright (c) 2019 RWTH Aachen University
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
## JS Template
This template includes:
* Typescript template
* Linting using TSLint
* Automatic releases using semantic-release (ESLint Code Convention) and Gitlab CI / CD
* For public registry: Publishing of packages, for usage add the following lines to package.json, add the npm publish module in .releaserc and provide a valid NPM token:
```
"publishConfig": {
"access": "public",
"registry": "https://registry.npmjs.org/",
"tag": "latest"
}
```
* Set "{Provider}", "{RepositoryName}" and "{RepositoryPath}" in package.json
* Automatic Unit tests using Mocha
* Automatic documentation publishing using Gitlab CI / CD and a self written script which puts the docs in the docs folder to the wiki
\ No newline at end of file
## ESLint Convention
Make the changes to the code and tests and then commit to your branch. Be sure to follow the commit message conventions.
Commit message summaries must follow this basic format:
```
Tag: Message (fixes #1234)
```
`Tag` should not be confused with git tag.
`Message` should not be confused with git commit message.
The `Tag` is one of the following:
* `Fix` - for a bug fix.
* `Update` - for a backwards-compatible enhancement.
* `Breaking` - for a backwards-incompatible enhancement.
* `Docs` - changes to documentation only.
* `Build` - changes to build process only.
* `New` - implemented a new feature.
* `Upgrade` - for a dependency upgrade.
The message summary should be a one-sentence description of the change. The issue number should be mentioned at the end. * The commit message should say "(fixes #1234)" at the end of the description if it closes out an existing issue (replace 1234 with the issue number). If the commit doesn't completely fix the issue, then use `(refs #1234)` instead of `(fixes #1234)`.
Here are some good commit message summary examples:
```
Build: Update Travis to only test Node 0.10 (refs #734)
Fix: Semi rule incorrectly flagging extra semicolon (fixes #840)
Upgrade: Esprima to 1.2, switch to using Esprima comment attachment (fixes #730)
```
The commit message format is important because these messages are used to create a changelog for each release. The tag and issue number help to create more consistent and useful changelogs.
Based on https://github.com/eslint/eslint.github.io/blob/master/docs/developer-guide/contributing.md#step-2-make-your-changes
[npm-image]: https://badge.fury.io/js/conventional-changelog-eslint.svg
[npm-url]: https://npmjs.org/package/conventional-changelog-eslint
[travis-image]: https://travis-ci.org/stevemao/conventional-changelog-eslint.svg?branch=master
[travis-url]: https://travis-ci.org/stevemao/conventional-changelog-eslint
[daviddm-image]: https://david-dm.org/stevemao/conventional-changelog-eslint.svg?theme=shields.io
[daviddm-url]: https://david-dm.org/stevemao/conventional-changelog-eslint
[coveralls-image]: https://coveralls.io/repos/stevemao/conventional-changelog-eslint/badge.svg
[coveralls-url]: https://coveralls.io/r/stevemao/conventional-changelog-eslint
\ No newline at end of file
## JS Template
This template includes:
* Typescript template
* Linting using TSLint
* Automatic releases using semantic-release (ESLint Code Convention) and Gitlab CI / CD
* For public registry: Publishing of packages, for usage add the following lines to package.json, add the npm publish module in .releaserc and provide a valid NPM token:
```
"publishConfig": {
"access": "public",
"registry": "https://registry.npmjs.org/",
"tag": "latest"
}
```
* Set "{Provider}", "{RepositoryName}" and "{RepositoryPath}" in package.json
* Automatic Unit tests using Mocha
* Automatic documentation publishing using Gitlab CI / CD and a self written script which puts the docs in the docs folder to the wiki
### Links
* [Commit convention](ESLintConvention)
* [Everything possible with markup](testdoc)
\ No newline at end of file
It's very easy to make some words **bold** and other words *italic* with Markdown. You can even [link to Google!](http://google.com)
Sometimes you want numbered lists:
1. One
2. Two
3. Three
Sometimes you want bullet points:
* Start a line with a star
* Profit!
Alternatively,
- Dashes work just as well
- And if you have sub points, put two spaces before the dash or star:
- Like this
- And this
If you want to embed images, this is how you do it:
![Image of Yaktocat](https://octodex.github.com/images/yaktocat.png)
# Structured documents
Sometimes it's useful to have different levels of headings to structure your documents. Start lines with a `#` to create headings. Multiple `##` in a row denote smaller heading sizes.
### This is a third-tier heading
You can use one `#` all the way up to `######` six for different heading sizes.
If you'd like to quote someone, use the > character before the line:
> Coffee. The finest organic suspension ever devised... I beat the Borg with it.
> - Captain Janeway
[200~There are many different ways to style code with GitHub's markdown. If you have inline code blocks, wrap them in backticks: `var example = true`. If you've got a longer block of code, you can indent with four spaces:
if (isAwesome){
return true
}
GitHub also supports something called code fencing, which allows for multiple lines without indentation:
```
if (isAwesome){
return true
}
```
And if you'd like to use syntax highlighting, include the language:
```javascript
if (isAwesome){
return true
}
```
GitHub supports many extras in Markdown that help you reference and link to people. If you ever want to direct a comment at someone, you can prefix their name with an @ symbol: Hey @kneath — love your sweater!
But I have to admit, tasks lists are my favorite:
- [x] This is a complete item
- [ ] This is an incomplete item
When you include a task list in the first comment of an Issue, you will see a helpful progress bar in your list of issues. It works in Pull Requests, too!
And, of course emoji!
GitHub supports many extras in Markdown that help you reference and link to people. If you ever want to direct a comment at someone, you can prefix their name with an @ symbol: Hey @kneath — love your sweater!
But I have to admit, tasks lists are my favorite:
This is a complete item
This is an incomplete item
When you include a task list in the first comment of an Issue, you will see a helpful progress bar in your list of issues. It works in Pull Requests, too!
And, of course emoji!
const gulp = require('gulp');
const path = require('path');
const merge = require('merge-stream');
const wrap = require('gulp-wrap');
const declare = require('gulp-declare');
const concat = require('gulp-concat');
const typescript = require('gulp-typescript');
function cprPromise(src, dest, options) {
const cpr = require('cpr');
return new Promise(function(resolve, reject) {
cpr(src, dest, options, function(err, files) {
if (err) {
reject(err);
} else {
resolve(files);
}
})
});
}
function copyOtherFiles(deleteFirst) {
// Copy files to dist folder
return cprPromise('.', 'dist', {
deleteFirst: deleteFirst, // Delete "to" before
overwrite: true, // If the file exists, overwrite it
filter: /(^dist|^typings|^package.json|^package-lock.json|^\..*|^node_modules|^etc|^webpack.config|^web.config|^gulpfile.js|^tsconfig.json|^.*\.ts$|^.*\.scss$|^.*\.hbs$)/
}).then(function() {
// Copy typings
return cprPromise('src/typings', 'dist/typings', {
deleteFirst: deleteFirst,
overwrite: true,
});
});
}
gulp.task('copy-files-clean', function() {
return copyOtherFiles(true);
});
gulp.task('copy-files', function() {
return copyOtherFiles(false);
});
gulp.task('sass', function () {
const sass = require('gulp-sass');
const autoprefixer = require('gulp-autoprefixer');
return gulp.src('./{templates,css,scss,styles}/**/*.scss')
.pipe(sass.sync({
outputStyle: "expanded",
indentWidth: 4
})
.on('error', function (error) {
sass.logError(error);
process.exit(1);
}))
.pipe(autoprefixer({
browsers: [
'last 2 versions',
'Chrome >= 30',
'Firefox >= 30',
'ie >= 10',
'Safari >= 8']
}))
.pipe(gulp.dest('./dist/'));
});
gulp.task('templates', function () {
const handlebars = require('gulp-handlebars');
var partials = gulp.src(['templates/**/*.hbs'])
.pipe(handlebars({
handlebars: require('handlebars')
}))
.pipe(wrap('Handlebars.registerPartial(<%= processPartialName(file.relative) %>, Handlebars.template(<%= contents %>));', {}, {
imports: {
processPartialName: function (fileName) {
// Strip the extension
// Escape the output with JSON.stringify
return JSON.stringify(path.basename(fileName, '.js'));
}
}
}));
var templates = gulp.src('templates/**/*.hbs')
.pipe(handlebars({
handlebars: require('handlebars')
}))
.pipe(wrap('Handlebars.template(<%= contents %>)'))
.pipe(declare({
namespace: 'PuFeLabs.handlebars.templates',
noRedeclare: true, // Avoid duplicate declarations
}));
// Output both the partials and the templates as build/js/templates.js
return merge(partials, templates)
.pipe(concat('templates.js'))
.pipe(gulp.dest('dist/scripts'));
});
gulp.task('typescript', function () {
const sourcemaps = require('gulp-sourcemaps');
const tsProject = typescript.createProject('tsconfig.json');
// Check if running in production mode
if (process.env.PITLABS_ENV === 'production') {
return tsProject.src()
.pipe(tsProject(typescript.reporter.longReporter()))
.on('error', function (error) {
process.exit(1);
})
.js
.pipe(gulp.dest('dist'));
} else {
// Development mode (default), generate sourcemaps
return tsProject.src()
.pipe(sourcemaps.init()) // Generate source maps as well
.pipe(tsProject(typescript.reporter.longReporter()))
.on('error', function (error) {
process.exit(1);
})
.js
.pipe(sourcemaps.write({
sourceRoot: "../."
}))
.pipe(gulp.dest('dist'));
}
});
gulp.task('ts-definitions', function () {
const tsProject = typescript.createProject('tsconfig.json', { declaration: true });
return tsProject.src()
.pipe(tsProject(typescript.reporter.longReporter()))
.on('error', function (error) {
process.exit(1);
})
.dts
.pipe(gulp.dest('dist/typings'));
});
gulp.task('watch', function () {
// gulp.watch('./{templates,css,scss}/**/*.scss', gulp.series('sass'));
// gulp.watch('templates/**/*.hbs', gulp.series('templates'));
// gulp.watch('**/*.ts', gulp.series('typescript'));
// TODO Ignoring the dist folder currently does not work
// gulp.watch('**/*.*', { ignore: 'dist/**/*.*' }, gulp.series('copy-files'));
});
gulp.task('build', gulp.series(
'copy-files-clean',
gulp.parallel(
'typescript',
'sass',
'templates',
'ts-definitions'
)
));
\ No newline at end of file
{
"name": "@{Provider}/{RepositoryName}",
"version": "1.0.0",
"description": "",
"main": "index.js",
"scripts": {
"build": "gulp build",
"test": "tslint \"src/**\" && mocha \"./test/*.js\""
},
"repository": {
"type": "git",
"url": "git@git.rwth-aachen.de:coscine/{RepositoryPath}.git"
},
"keywords": [],
"author": "",
"license": "ISC",
"devDependencies": {
"@semantic-release/commit-analyzer": "^6.1.0",
"@semantic-release/git": "^7.0.5",
"@semantic-release/gitlab": "^3.0.5",
"@semantic-release/npm": "^5.1.1",
"@semantic-release/release-notes-generator": "^7.1.4",
"@types/handlebars": "^4.0.36",
"@types/jquery": "^3.3.5",
"conventional-changelog-eslint": "^3.0.1",
"cpr": "^2.2.0",
"eslint": "^5.15.1",
"eslint-config-google": "^0.12.0",
"eslint-plugin-vue": "^5.2.2",
"gulp": "^4.0.0",
"gulp-autoprefixer": "^4.1.0",
"gulp-concat": "^2.6.1",
"gulp-declare": "^0.3.0",
"gulp-handlebars": "^5.0.2",
"gulp-sass": "^3.1.0",
"gulp-sourcemaps": "^2.6.4",
"gulp-typescript": "^4.0.1",
"gulp-wrap": "^0.13.0",
"handlebars": "^3.0.3",
"merge-stream": "^1.0.1",
"mocha": "^5.0.1",
"run-sequence": "^2.2.0",
"semantic-release": "^15.12.0",
"semantic-release-gitlab": "^7.1.0",
"tslint": "^5.13.1",
"typescript": "^3.3.3333"
},
"publishConfig": {
"access": "public",
"tag": "latest"
},
"dependencies": {
"@types/node": "^10.12.30"
}
}
param(
$token
)
$remoteUrl = git config --get remote.origin.url
$remoteUrl = $remoteUrl.replace("git@", "")
$remoteUrl = $remoteUrl -replace "https(.*?)@",""
$remoteUrl = $remoteUrl.replace(":", "/")
$remoteUrl = $remoteUrl.replace(".git", ".wiki.git")
$temporaryFolderName = "publishDocsTempFolder"
git clone "https://gitlab-ci-token:$($token)@$($remoteUrl)" $temporaryFolderName
cd $temporaryFolderName
Remove-Item *
cp -r ../docs/* ./
git add .
git commit -m "Docs: Documentation Update"
git push
\ No newline at end of file
Source Code gets put here
\ No newline at end of file
Test Code gets put here
\ No newline at end of file
{
"compilerOptions": {
"strict": true,
"noEmitOnError": false,
"removeComments": false,
"sourceMap": true,
"target": "es6",
"outDir": "dist",
"allowUnreachableCode": false,
"suppressImplicitAnyIndexErrors": true,
"rootDir": ".",
"module": "commonjs",
"moduleResolution": "node",
"lib": [ "dom", "es2015.promise", "es5" ],
"skipLibCheck": true,
"typeRoots": ["node_modules/@types", "typings"]
},
"exclude": [
"node_modules",
"dist"
]
}
{
"extends": "tslint:recommended",
"rules": {
"max-line-length": {
"options": [120]
},
"new-parens": true,
"no-arg": true,
"no-bitwise": true,
"no-conditional-assignment": true,
"no-consecutive-blank-lines": false,
"no-console": {
"severity": "warning",
"options": ["debug", "info", "log", "time", "timeEnd", "trace"]
}
},
"jsRules": {
"max-line-length": {
"options": [120]
}
},
"defaultSeverity": "warning"
}
\ No newline at end of file
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment