✨ Add test project with argument
This commit is contained in:
@@ -9,6 +9,8 @@ const socketIo = require('socket.io')
|
||||
const util = require('util')
|
||||
const colors = require('colors')
|
||||
const opener = require('opener')
|
||||
const fs = require('fs')
|
||||
const path = require('path')
|
||||
|
||||
/**
|
||||
* App class
|
||||
@@ -30,6 +32,7 @@ class App
|
||||
{
|
||||
this.setSocket()
|
||||
this.setProjects()
|
||||
this.setTest()
|
||||
},
|
||||
() =>
|
||||
{
|
||||
@@ -89,6 +92,12 @@ class App
|
||||
default: true,
|
||||
type: 'boolean'
|
||||
})
|
||||
.option('test', {
|
||||
alias: 't',
|
||||
describe: 'Start a test project',
|
||||
default: false,
|
||||
type: 'boolean'
|
||||
})
|
||||
.option('initial-send', {
|
||||
alias: 'i',
|
||||
describe: 'Send current file in folder immediately',
|
||||
@@ -108,6 +117,7 @@ class App
|
||||
config.port = args.port
|
||||
config.exclude = args.exclude
|
||||
config.open = args.open
|
||||
config.test = args.test
|
||||
config.initialSend = args['initial-send']
|
||||
config.maxFileSize = args['max-file-size']
|
||||
|
||||
@@ -267,6 +277,122 @@ class App
|
||||
{
|
||||
this.watcher = new Watcher(this.config)
|
||||
}
|
||||
|
||||
/**
|
||||
* Set Test
|
||||
*/
|
||||
setTest()
|
||||
{
|
||||
if(!this.config.test)
|
||||
{
|
||||
return
|
||||
}
|
||||
|
||||
console.log('app'.green.bold + ' - ' + 'start test folder'.cyan)
|
||||
|
||||
// Default project
|
||||
const project = this.projects.createProject('Test project')
|
||||
this.site.createProject(project.slug, path.join(__dirname, '../test/demo-folder/'))
|
||||
|
||||
// // Same name projects
|
||||
// let project_2 = this.projects.createProject('dummy')
|
||||
// let project_3 = this.projects.createProject('dummy')
|
||||
// let project_4 = this.projects.createProject('dummy')
|
||||
// let project_5 = this.projects.createProject('dummy')
|
||||
|
||||
// Some file
|
||||
// project.files.createVersion('./folder-test/test-4.css', fs.readFileSync('../test/demo-folder/folder-1/test-4.css', 'utf8'))
|
||||
// project.files.createVersion('./folder-test/depth-test/test-3.js', fs.readFileSync('../test/demo-folder/folder-2/test-3.js', 'utf8'))
|
||||
// project.files.createVersion('./folder-test/depth-test/test-3.js', fs.readFileSync('../test/demo-folder/folder-2/test-3-diff-1.js', 'utf8'))
|
||||
// project.files.createVersion('./folder-test/depth-test/test-3.js', fs.readFileSync('../test/demo-folder/folder-2/test-3-diff-2.js', 'utf8'))
|
||||
// project.files.createVersion('./folder-test/depth-test/test-3.js', fs.readFileSync('../test/demo-folder/folder-2/test-3-diff-3.js', 'utf8'))
|
||||
// project.files.createVersion('./folder-test/depth-test/test-3.js', fs.readFileSync('../test/demo-folder/folder-2/test-3-diff-4.js', 'utf8'))
|
||||
// project.files.createVersion('./folder-test/test-1.html', fs.readFileSync('../test/demo-folder/test-1.html', 'utf8'))
|
||||
// project.files.createVersion('./folder-test/test-2.php', fs.readFileSync('../test/demo-folder/test-2.php', 'utf8'))
|
||||
// project.files.createVersion('./folder-test/big-one.txt', 'line\nline\nline\nline\nline\nline\nline\nline\nline\nline\nline\nline\nline\nline\nline\nline\nline\nline\nline\nline\nline\nline\nline\nline\nline\nline\nline\nline\nline\nline\nline\nline\nline\nline\nline\nline\nline\nline\nline\nline\nline\nline\nline\nline\nline\nline\nline\nline\nline\nline\nline\nline\nline\nline\nline\nline\nline\nline\nline\nline\nline\nline\nline\nline\nline\nline\nline\nline\nline\nline\nline\nline\nline\nline\nline\nline\nline\nline\nline\nline\nline\nline\nline\nline\nline\nline\nline\nline\nline\nline\nline\nline\nline\nline\nline\nline\nline\nline\nline\nline\nline')
|
||||
// project.files.createVersion('./folder-test/loooooooooooooooooooooooooooooooong-one.txt', 'abcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyz')
|
||||
|
||||
project.files.createVersion('./icons/test.js', 'Test icon')
|
||||
project.files.createVersion('./icons/test.html', 'Test icon')
|
||||
project.files.createVersion('./icons/test.sass', 'Test icon')
|
||||
project.files.createVersion('./icons/test.scss', 'Test icon')
|
||||
project.files.createVersion('./icons/test.less', 'Test icon')
|
||||
project.files.createVersion('./icons/test.stylus', 'Test icon')
|
||||
project.files.createVersion('./icons/test.styl', 'Test icon')
|
||||
project.files.createVersion('./icons/test.css', 'Test icon')
|
||||
project.files.createVersion('./icons/test.php', 'Test icon')
|
||||
project.files.createVersion('./icons/test.json', 'Test icon')
|
||||
project.files.createVersion('./icons/test.jade', 'Test icon')
|
||||
project.files.createVersion('./icons/test.pug', 'Test icon')
|
||||
project.files.createVersion('./icons/test.md', 'Test icon')
|
||||
project.files.createVersion('./icons/test.sql', 'Test icon')
|
||||
project.files.createVersion('./icons/test.htaccess', 'Test icon')
|
||||
project.files.createVersion('./icons/test.htpasswd', 'Test icon')
|
||||
project.files.createVersion('./icons/test.yml', 'Test icon')
|
||||
project.files.createVersion('./icons/test.svg', 'Test icon')
|
||||
project.files.createVersion('./icons/test.eot', 'Test icon')
|
||||
project.files.createVersion('./icons/test.ttf', 'Test icon')
|
||||
project.files.createVersion('./icons/test.woff', 'Test icon')
|
||||
project.files.createVersion('./icons/test.woff2', 'Test icon')
|
||||
project.files.createVersion('./icons/test.jpeg', 'Test icon')
|
||||
project.files.createVersion('./icons/test.jpg', 'Test icon')
|
||||
project.files.createVersion('./icons/test.tiff', 'Test icon')
|
||||
project.files.createVersion('./icons/test.gif', 'Test icon')
|
||||
project.files.createVersion('./icons/test.bmp', 'Test icon')
|
||||
project.files.createVersion('./icons/test.png', 'Test icon')
|
||||
project.files.createVersion('./icons/test.webp', 'Test icon')
|
||||
project.files.createVersion('./icons/test.mpeg', 'Test icon')
|
||||
project.files.createVersion('./icons/test.mpg', 'Test icon')
|
||||
project.files.createVersion('./icons/test.mp4', 'Test icon')
|
||||
project.files.createVersion('./icons/test.amv', 'Test icon')
|
||||
project.files.createVersion('./icons/test.wmv', 'Test icon')
|
||||
project.files.createVersion('./icons/test.mov', 'Test icon')
|
||||
project.files.createVersion('./icons/test.avi', 'Test icon')
|
||||
project.files.createVersion('./icons/test.ogv', 'Test icon')
|
||||
project.files.createVersion('./icons/test.mkv', 'Test icon')
|
||||
project.files.createVersion('./icons/test.webm', 'Test icon')
|
||||
project.files.createVersion('./icons/test.mp3', 'Test icon')
|
||||
project.files.createVersion('./icons/test.wav', 'Test icon')
|
||||
project.files.createVersion('./icons/test.ogg', 'Test icon')
|
||||
project.files.createVersion('./icons/test.raw', 'Test icon')
|
||||
project.files.createVersion('./icons/test.zip', 'Test icon')
|
||||
project.files.createVersion('./icons/test.rar', 'Test icon')
|
||||
project.files.createVersion('./icons/test.7z', 'Test icon')
|
||||
project.files.createVersion('./icons/test.gz', 'Test icon')
|
||||
project.files.createVersion('./icons/test.txt', 'Test icon')
|
||||
project.files.createVersion('./icons/test.coffee', 'Test icon')
|
||||
project.files.createVersion('./icons/test.gitignore', 'Test icon')
|
||||
project.files.createVersion('./icons/test.gitkeep', 'Test icon')
|
||||
project.files.createVersion('./icons/test.xml', 'Test icon')
|
||||
project.files.createVersion('./icons/test.twig', 'Test icon')
|
||||
project.files.createVersion('./icons/test.c', 'Test icon')
|
||||
project.files.createVersion('./icons/test.h', 'Test icon')
|
||||
project.files.createVersion('./icons/test.pwet', 'Test icon')
|
||||
|
||||
// project.files.createVersion('./toto/tata/lorem.txt', '123456789')
|
||||
// project.files.createVersion('./toto/tata/lorem.txt', '1aze')
|
||||
// project.files.createVersion('./toto/tata/ipsum.txt', 'Lorem ipsum dolor sit amet, consectetur adipisicing elit. Mollitia asperiores iure, animi voluptatibus ut officiis. Molestias, quod perferendis hic totam doloremque, porro aperiam enim tenetur, maxime inventore consequuntur nisi in?')
|
||||
|
||||
// Adding file versions
|
||||
let counting = 0
|
||||
setInterval(function()
|
||||
{
|
||||
project.files.createVersion('./folder-test/multi-version.txt', 'test: ' + counting++)
|
||||
}, 2000)
|
||||
|
||||
// Creating and deleting file
|
||||
let toggle = true
|
||||
setInterval(function()
|
||||
{
|
||||
if(toggle)
|
||||
project.files.create('./folder-test/toggle.txt', 'content')
|
||||
else
|
||||
project.files.delete('./folder-test/toggle.txt', 'content')
|
||||
|
||||
toggle = !toggle
|
||||
}, 3000)
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
module.exports = App
|
||||
|
||||
+9
-9
@@ -33,7 +33,7 @@ class Projects
|
||||
{
|
||||
// Create project
|
||||
const project = new Project(this.config, { name: _name })
|
||||
let sameNameProject = this.all[ project.slug ]
|
||||
let sameNameProject = this.all[project.slug]
|
||||
|
||||
// Try to found same name project
|
||||
while(typeof sameNameProject !== 'undefined')
|
||||
@@ -44,7 +44,7 @@ class Projects
|
||||
|
||||
if(lastNumber && lastNumber.length)
|
||||
{
|
||||
lastNumber = ~~lastNumber[ 0 ]
|
||||
lastNumber = ~~lastNumber[0]
|
||||
|
||||
newNumber = lastNumber + 1
|
||||
}
|
||||
@@ -53,11 +53,11 @@ class Projects
|
||||
project.set_name(_name + ' ' + newNumber)
|
||||
|
||||
// Try to found
|
||||
sameNameProject = this.all[ project.slug ]
|
||||
sameNameProject = this.all[project.slug]
|
||||
}
|
||||
|
||||
// Save
|
||||
this.all[ project.slug ] = project
|
||||
this.all[project.slug] = project
|
||||
|
||||
// Emit
|
||||
this.projectsSocket.emit('update_projects', this.describe())
|
||||
@@ -69,13 +69,13 @@ class Projects
|
||||
deleteProject(_slug)
|
||||
{
|
||||
// Set up
|
||||
const project = this.all[ _slug ]
|
||||
const project = this.all[_slug]
|
||||
|
||||
// Project found
|
||||
if(typeof project !== 'undefined')
|
||||
{
|
||||
// Delete
|
||||
delete this.all[ _slug ]
|
||||
delete this.all[_slug]
|
||||
project.destructor()
|
||||
|
||||
// Emit
|
||||
@@ -86,7 +86,7 @@ class Projects
|
||||
getProjectBySlug(_slug)
|
||||
{
|
||||
// Find project
|
||||
const project = this.all[ _slug ]
|
||||
const project = this.all[_slug]
|
||||
|
||||
// Found
|
||||
if(project)
|
||||
@@ -105,9 +105,9 @@ class Projects
|
||||
|
||||
for(const _slug in this.all)
|
||||
{
|
||||
const _project = this.all[ _slug ]
|
||||
const _project = this.all[_slug]
|
||||
|
||||
result.all[ _slug ] = {
|
||||
result.all[_slug] = {
|
||||
slug: _project.slug,
|
||||
name: _project.name,
|
||||
filesCount: _project.files.count,
|
||||
|
||||
-118
@@ -5,9 +5,7 @@ const express = require('express')
|
||||
const helmet = require('helmet')
|
||||
const http = require('http')
|
||||
const colors = require('colors')
|
||||
const util = require('util')
|
||||
const path = require('path')
|
||||
const fs = require('fs')
|
||||
|
||||
/**
|
||||
* Site class
|
||||
@@ -26,124 +24,8 @@ class Site
|
||||
|
||||
this.setExpress()
|
||||
this.setServer()
|
||||
// this.setDummy()
|
||||
}
|
||||
|
||||
// /**
|
||||
// * Set Dummy
|
||||
// */
|
||||
// setDummy()
|
||||
// {
|
||||
// if(!this.config.debug)
|
||||
// {
|
||||
// return
|
||||
// }
|
||||
|
||||
// // Default project
|
||||
// const project = this.projects.createProject('Dummy project')
|
||||
|
||||
// // // Same name projects
|
||||
// // let project_2 = this.projects.createProject('dummy')
|
||||
// // let project_3 = this.projects.createProject('dummy')
|
||||
// // let project_4 = this.projects.createProject('dummy')
|
||||
// // let project_5 = this.projects.createProject('dummy')
|
||||
|
||||
// // Some file
|
||||
// project.files.createVersion('./folder-test/test-4.css', fs.readFileSync('../test-folder/folder-1/test-4.css', 'utf8'))
|
||||
// project.files.createVersion('./folder-test/depth-test/test-3.js', fs.readFileSync('../test-folder/folder-2/test-3.js', 'utf8'))
|
||||
// project.files.createVersion('./folder-test/depth-test/test-3.js', fs.readFileSync('../test-folder/folder-2/test-3-diff-1.js', 'utf8'))
|
||||
// project.files.createVersion('./folder-test/depth-test/test-3.js', fs.readFileSync('../test-folder/folder-2/test-3-diff-2.js', 'utf8'))
|
||||
// project.files.createVersion('./folder-test/depth-test/test-3.js', fs.readFileSync('../test-folder/folder-2/test-3-diff-3.js', 'utf8'))
|
||||
// project.files.createVersion('./folder-test/depth-test/test-3.js', fs.readFileSync('../test-folder/folder-2/test-3-diff-4.js', 'utf8'))
|
||||
// project.files.createVersion('./folder-test/test-1.html', fs.readFileSync('../test-folder/test-1.html', 'utf8'))
|
||||
// project.files.createVersion('./folder-test/test-2.php', fs.readFileSync('../test-folder/test-2.php', 'utf8'))
|
||||
// project.files.createVersion('./folder-test/big-one.txt', 'line\nline\nline\nline\nline\nline\nline\nline\nline\nline\nline\nline\nline\nline\nline\nline\nline\nline\nline\nline\nline\nline\nline\nline\nline\nline\nline\nline\nline\nline\nline\nline\nline\nline\nline\nline\nline\nline\nline\nline\nline\nline\nline\nline\nline\nline\nline\nline\nline\nline\nline\nline\nline\nline\nline\nline\nline\nline\nline\nline\nline\nline\nline\nline\nline\nline\nline\nline\nline\nline\nline\nline\nline\nline\nline\nline\nline\nline\nline\nline\nline\nline\nline\nline\nline\nline\nline\nline\nline\nline\nline\nline\nline\nline\nline\nline\nline\nline\nline\nline\nline')
|
||||
// project.files.createVersion('./folder-test/loooooooooooooooooooooooooooooooong-one.txt', 'abcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyz')
|
||||
|
||||
// project.files.createVersion('./icons/test.js', 'Test icon')
|
||||
// project.files.createVersion('./icons/test.html', 'Test icon')
|
||||
// project.files.createVersion('./icons/test.sass', 'Test icon')
|
||||
// project.files.createVersion('./icons/test.scss', 'Test icon')
|
||||
// project.files.createVersion('./icons/test.less', 'Test icon')
|
||||
// project.files.createVersion('./icons/test.stylus', 'Test icon')
|
||||
// project.files.createVersion('./icons/test.styl', 'Test icon')
|
||||
// project.files.createVersion('./icons/test.css', 'Test icon')
|
||||
// project.files.createVersion('./icons/test.php', 'Test icon')
|
||||
// project.files.createVersion('./icons/test.json', 'Test icon')
|
||||
// project.files.createVersion('./icons/test.jade', 'Test icon')
|
||||
// project.files.createVersion('./icons/test.pug', 'Test icon')
|
||||
// project.files.createVersion('./icons/test.md', 'Test icon')
|
||||
// project.files.createVersion('./icons/test.sql', 'Test icon')
|
||||
// project.files.createVersion('./icons/test.htaccess', 'Test icon')
|
||||
// project.files.createVersion('./icons/test.htpasswd', 'Test icon')
|
||||
// project.files.createVersion('./icons/test.yml', 'Test icon')
|
||||
// project.files.createVersion('./icons/test.svg', 'Test icon')
|
||||
// project.files.createVersion('./icons/test.eot', 'Test icon')
|
||||
// project.files.createVersion('./icons/test.ttf', 'Test icon')
|
||||
// project.files.createVersion('./icons/test.woff', 'Test icon')
|
||||
// project.files.createVersion('./icons/test.woff2', 'Test icon')
|
||||
// project.files.createVersion('./icons/test.jpeg', 'Test icon')
|
||||
// project.files.createVersion('./icons/test.jpg', 'Test icon')
|
||||
// project.files.createVersion('./icons/test.tiff', 'Test icon')
|
||||
// project.files.createVersion('./icons/test.gif', 'Test icon')
|
||||
// project.files.createVersion('./icons/test.bmp', 'Test icon')
|
||||
// project.files.createVersion('./icons/test.png', 'Test icon')
|
||||
// project.files.createVersion('./icons/test.webp', 'Test icon')
|
||||
// project.files.createVersion('./icons/test.mpeg', 'Test icon')
|
||||
// project.files.createVersion('./icons/test.mpg', 'Test icon')
|
||||
// project.files.createVersion('./icons/test.mp4', 'Test icon')
|
||||
// project.files.createVersion('./icons/test.amv', 'Test icon')
|
||||
// project.files.createVersion('./icons/test.wmv', 'Test icon')
|
||||
// project.files.createVersion('./icons/test.mov', 'Test icon')
|
||||
// project.files.createVersion('./icons/test.avi', 'Test icon')
|
||||
// project.files.createVersion('./icons/test.ogv', 'Test icon')
|
||||
// project.files.createVersion('./icons/test.mkv', 'Test icon')
|
||||
// project.files.createVersion('./icons/test.webm', 'Test icon')
|
||||
// project.files.createVersion('./icons/test.mp3', 'Test icon')
|
||||
// project.files.createVersion('./icons/test.wav', 'Test icon')
|
||||
// project.files.createVersion('./icons/test.ogg', 'Test icon')
|
||||
// project.files.createVersion('./icons/test.raw', 'Test icon')
|
||||
// project.files.createVersion('./icons/test.zip', 'Test icon')
|
||||
// project.files.createVersion('./icons/test.rar', 'Test icon')
|
||||
// project.files.createVersion('./icons/test.7z', 'Test icon')
|
||||
// project.files.createVersion('./icons/test.gz', 'Test icon')
|
||||
// project.files.createVersion('./icons/test.txt', 'Test icon')
|
||||
// project.files.createVersion('./icons/test.coffee', 'Test icon')
|
||||
// project.files.createVersion('./icons/test.gitignore', 'Test icon')
|
||||
// project.files.createVersion('./icons/test.gitkeep', 'Test icon')
|
||||
// project.files.createVersion('./icons/test.xml', 'Test icon')
|
||||
// project.files.createVersion('./icons/test.twig', 'Test icon')
|
||||
// project.files.createVersion('./icons/test.c', 'Test icon')
|
||||
// project.files.createVersion('./icons/test.h', 'Test icon')
|
||||
// project.files.createVersion('./icons/test.pwet', 'Test icon')
|
||||
|
||||
// // project.files.createVersion('./toto/tata/lorem.txt', '123456789')
|
||||
// // project.files.createVersion('./toto/tata/lorem.txt', '1aze')
|
||||
// // project.files.createVersion('./toto/tata/ipsum.txt', 'Lorem ipsum dolor sit amet, consectetur adipisicing elit. Mollitia asperiores iure, animi voluptatibus ut officiis. Molestias, quod perferendis hic totam doloremque, porro aperiam enim tenetur, maxime inventore consequuntur nisi in?')
|
||||
|
||||
// // Adding file versions
|
||||
// let counting = 0
|
||||
// setInterval(function()
|
||||
// {
|
||||
// project.files.createVersion('./folder-test/multi-version.txt', 'test: ' + counting++)
|
||||
// }, 2000)
|
||||
|
||||
// // Creating and deleting file
|
||||
// let toggle = true
|
||||
// setInterval(function()
|
||||
// {
|
||||
// if(toggle)
|
||||
// project.files.create('./folder-test/toggle.txt', 'content')
|
||||
// else
|
||||
// project.files.delete('./folder-test/toggle.txt', 'content')
|
||||
|
||||
// toggle = !toggle
|
||||
// }, 3000)
|
||||
|
||||
// // // Log
|
||||
// // console.log(util.inspect(project.files.describe(), { depth: null, colors: true }))
|
||||
// }
|
||||
|
||||
/**
|
||||
* Set express
|
||||
* Start express and set controllers
|
||||
|
||||
+2
-1
@@ -7,7 +7,8 @@
|
||||
},
|
||||
"main": "bin/index.js",
|
||||
"scripts": {
|
||||
"demo-folder": "cd test/demo-folder && node ../../bin 'Demo folder' --debug 1"
|
||||
"demo-folder": "cd test/demo-folder && node ../../bin 'Demo folder' --debug 1",
|
||||
"test-project": "node ./bin --debug 1 --test"
|
||||
},
|
||||
"repository": {
|
||||
"type": "git",
|
||||
|
||||
Reference in New Issue
Block a user