sinto 1.2.3 → 1.3.0
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.
- package/generators/genGulpfile.js +23 -13
- package/generators/genHtml.js +1 -1
- package/generators/genPackage.js +5 -2
- package/gentest/generate.js +16 -0
- package/gentest/testPupContent.js +27 -0
- package/package.json +1 -1
- package/sin.js +2 -0
|
@@ -1,38 +1,48 @@
|
|
|
1
1
|
|
|
2
2
|
const gulfileContent = `
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
3
|
+
import {src, dest, parallel} from 'gulp';
|
|
4
|
+
import cleanCss from 'gulp-clean-css';
|
|
5
|
+
import replace from 'gulp-replace';
|
|
6
|
+
import minify from 'gulp-minify';
|
|
7
|
+
import concat from 'gulp-concat'
|
|
8
|
+
|
|
9
|
+
import {create as bsCreate} from 'browser-sync';
|
|
10
|
+
const browserSync = bsCreate();
|
|
7
11
|
|
|
8
12
|
function genHTML(cb) {
|
|
9
|
-
console.log('HTML copying...');
|
|
10
13
|
src('src/**/*.html')
|
|
14
|
+
.pipe(replace(/app.js/g, 'app-min.js'))
|
|
11
15
|
.pipe(dest('public'))
|
|
12
16
|
cb();
|
|
13
17
|
}
|
|
14
18
|
|
|
15
19
|
function minifyJS(cb) {
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
.
|
|
20
|
+
src([
|
|
21
|
+
'src/**/*.js',
|
|
22
|
+
'node_modules/bootstrap/dist/js/bootstrap.js'
|
|
23
|
+
])
|
|
24
|
+
.pipe(replace(/import .*/g, ''))
|
|
25
|
+
.pipe(replace(/export .*/g, ''))
|
|
26
|
+
.pipe(concat('app.js'))
|
|
27
|
+
.pipe(minify())
|
|
19
28
|
.pipe(dest('public'));
|
|
20
29
|
cb();
|
|
21
30
|
}
|
|
22
|
-
|
|
31
|
+
|
|
23
32
|
function minifyCSS(cb) {
|
|
24
|
-
|
|
25
|
-
|
|
33
|
+
src([
|
|
34
|
+
'src/**/*.css',
|
|
35
|
+
'node_modules/bootstrap/dist/css/bootstrap.css'])
|
|
26
36
|
.pipe(cleanCss())
|
|
27
37
|
.pipe(dest('public'));
|
|
28
38
|
cb();
|
|
29
39
|
}
|
|
30
|
-
|
|
40
|
+
|
|
31
41
|
function build(cb) {
|
|
32
42
|
parallel(genHTML, minifyJS, minifyCSS)(cb);
|
|
33
43
|
}
|
|
34
44
|
|
|
35
|
-
|
|
45
|
+
export default build
|
|
36
46
|
|
|
37
47
|
`;
|
|
38
48
|
|
package/generators/genHtml.js
CHANGED
package/generators/genPackage.js
CHANGED
|
@@ -15,8 +15,11 @@ const packageContent =
|
|
|
15
15
|
"browser-sync": "^3.0.2",
|
|
16
16
|
"gulp": "^5.0.0",
|
|
17
17
|
"gulp-clean-css": "^4.3.0",
|
|
18
|
-
"gulp-
|
|
19
|
-
|
|
18
|
+
"gulp-concat": "^2.6.1",
|
|
19
|
+
"gulp-minify": "^3.1.0",
|
|
20
|
+
"gulp-replace": "^1.1.4"
|
|
21
|
+
},
|
|
22
|
+
"type": "module"
|
|
20
23
|
}
|
|
21
24
|
|
|
22
25
|
module.exports = packageContent;
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
const { createFile, createDirectory } = require('../tools/tools.js');
|
|
2
|
+
const puppeteerTestContent = require('./testPupContent')
|
|
3
|
+
|
|
4
|
+
const createPuppeteerTest = () => {
|
|
5
|
+
const dir = process.cwd();
|
|
6
|
+
createDirectory(`${dir}/test`);
|
|
7
|
+
createFile(`${dir}/test/apptest.js`, puppeteerTestContent);
|
|
8
|
+
console.log('\n')
|
|
9
|
+
console.log('Install the dependencies:')
|
|
10
|
+
console.log(' npm install --save-dev puppeteer mocha')
|
|
11
|
+
console.log('Add start script to package.json:')
|
|
12
|
+
console.log(' \"test\": \"mocha\"')
|
|
13
|
+
console.log('\n')
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
module.exports.createPuppeteerTest = createPuppeteerTest;
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
const puppeteerTestContent = `
|
|
2
|
+
import puppeteer from 'puppeteer'
|
|
3
|
+
import assert from 'assert'
|
|
4
|
+
|
|
5
|
+
describe('Weblap tartalmának tesztelése', () => {
|
|
6
|
+
let browser;
|
|
7
|
+
let page;
|
|
8
|
+
before(async function () {
|
|
9
|
+
browser = await puppeteer.launch({headless: true})
|
|
10
|
+
page = await browser.newPage()
|
|
11
|
+
await page.goto('http://localhost:3000')
|
|
12
|
+
})
|
|
13
|
+
after(async function() {
|
|
14
|
+
await browser.close()
|
|
15
|
+
})
|
|
16
|
+
it('Böngésző címsora', async function() {
|
|
17
|
+
const title = await page.title()
|
|
18
|
+
assert.strictEqual(title, 'Sinto Project')
|
|
19
|
+
})
|
|
20
|
+
it('h1 tartalma', async function() {
|
|
21
|
+
const content = await page.$eval('h1', element => element.textContent)
|
|
22
|
+
assert.strictEqual(content, 'Sinto Project')
|
|
23
|
+
})
|
|
24
|
+
})
|
|
25
|
+
|
|
26
|
+
`
|
|
27
|
+
module.exports = puppeteerTestContent
|
package/package.json
CHANGED
package/sin.js
CHANGED
|
@@ -7,6 +7,7 @@ const cli = require('./cli');
|
|
|
7
7
|
const serve = require('./server');
|
|
8
8
|
const { createApi } = require('./haiserver/apigen');
|
|
9
9
|
const { createWebpack } = require('./webpack/generate');
|
|
10
|
+
const { createPuppeteerTest } = require('./gentest/generate');
|
|
10
11
|
|
|
11
12
|
const {
|
|
12
13
|
createDirectory,
|
|
@@ -57,6 +58,7 @@ cli.command('build', 'Start build with gulp', {}, build);
|
|
|
57
58
|
cli.command('rmno', 'Delete node_modules directory', {}, rmno);
|
|
58
59
|
cli.command('api', 'REST API with hai-server', {}, createApi);
|
|
59
60
|
cli.command('webpack', 'Webpack client', {}, createWebpack);
|
|
61
|
+
cli.command('pup', 'Puppeteer test', {}, createPuppeteerTest);
|
|
60
62
|
|
|
61
63
|
const main = () => {
|
|
62
64
|
argv = cli.parse();
|