This repository has been archived by the owner on Dec 7, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Showing
25 changed files
with
978 additions
and
580 deletions.
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
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,3 +1,3 @@ | ||
# Current Branch Version | ||
|
||
**v3.8.4** | ||
**v3.8.5** |
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,18 @@ | ||
/* | ||
* Copyright (c) 2018-2019 João Pedro Martins Neves - All Rights Reserved. | ||
* | ||
* MergerJS (merger-js) is licensed under the MIT license, located in | ||
* the root of this project, under the name "LICENSE.md". | ||
* | ||
*/ | ||
|
||
|
||
const ImportType = Object.freeze( { | ||
Unknown: -1, | ||
RelativePath: 1, | ||
NodeModules: 2, | ||
SpecificURL: 3, | ||
GitHub: 4 | ||
} ); | ||
|
||
module.exports = ImportType; |
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,25 +1,40 @@ | ||
const StaticClass = require( '../models/staticClassBase' ); | ||
/* | ||
* Copyright (c) 2018-2019 João Pedro Martins Neves - All Rights Reserved. | ||
* | ||
* MergerJS (merger-js) is licensed under the MIT license, located in | ||
* the root of this project, under the name "LICENSE.md". | ||
* | ||
*/ | ||
|
||
const StaticClass = require( '../models/staticClassBase' ); | ||
|
||
class TokenType extends StaticClass { | ||
constructor() { | ||
super( 'TokenType' ); | ||
} | ||
|
||
static get token_push() { return '<<' } | ||
static get token_DIR() { return `${TokenType.token_push}DIR` } | ||
static get token_DIRECTORY() { return `${TokenType.token_push}DIRECTORY` } | ||
static get token_dir() { return `${TokenType.token_push}dir` } | ||
static get token_directory() { return `${TokenType.token_push}directory` } | ||
static get token_GH() { return `${TokenType.token_push}GH` } | ||
static get token_gh() { return `${TokenType.token_push}gh` } | ||
static get token_github() { return `${TokenType.token_push}github` } | ||
static get token_GITHUB() { return `${TokenType.token_push}GITHUB` } | ||
static get token_importPath_simbol() { return "@" } | ||
static get token_importPath() { return `${TokenType.token_importPath_simbol}import` } | ||
static get token_importNodeModules_simbol() { return "$" } | ||
static get token_importNodeModules() { return `${TokenType.token_importNodeModules_simbol}import` } | ||
static get token_importUrl_simbol() { return "%" } | ||
static get token_importUrl() { return `${TokenType.token_importUrl_simbol}import` } | ||
static get importPath_simbol() { return '@'; } | ||
static get importPath() { return `${TokenType.importPath_simbol}import`; } | ||
|
||
static get importNodeModules_simbol() { return '$'; } | ||
static get importNodeModules() { return `${TokenType.importNodeModules_simbol}import`; } | ||
|
||
static get importUrl_simbol() { return '%'; } | ||
static get doubleImportUrl_simbol() { return TokenType.importUrl_simbol + TokenType.importUrl_simbol; } | ||
static get importUrl() { return `${TokenType.importUrl_simbol}import`; } | ||
|
||
static get push_symbol() { return '<<'; } | ||
|
||
static get push_DIR() { return `${TokenType.push_symbol}DIR`; } | ||
static get push_DIRECTORY() { return `${TokenType.push_symbol}DIRECTORY`; } | ||
static get push_dir() { return `${TokenType.push_symbol}dir`; } | ||
static get push_directory() { return `${TokenType.push_symbol}directory`; } | ||
|
||
static get push_GH() { return `${TokenType.push_symbol}GH`; } | ||
static get push_gh() { return `${TokenType.push_symbol}gh`; } | ||
static get push_github() { return `${TokenType.push_symbol}github`; } | ||
static get push_GITHUB() { return `${TokenType.push_symbol}GITHUB`; } | ||
|
||
} | ||
|
||
module.exports = Object.freeze( TokenType ); |
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,8 @@ | ||
extensions: .js | ||
/* | ||
* Copyright (c) 2018-2019 João Pedro Martins Neves - All Rights Reserved. | ||
* | ||
* MergerJS (merger-js) is licensed under the MIT license, located in | ||
* the root of this project, under the name "LICENSE.md". | ||
* | ||
*/ |
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,18 @@ | ||
/* | ||
* Copyright (c) 2018-2019 João Pedro Martins Neves - All Rights Reserved. | ||
* | ||
* MergerJS (merger-js) is licensed under the MIT license, located in | ||
* the root of this project, under the name "LICENSE.md". | ||
* | ||
*/ | ||
|
||
const configKeys = Object.freeze( { | ||
minify: 'uglify', | ||
autoBuild: 'autoBuild', | ||
notifs: 'notifications', | ||
updateOnLaunch: 'updateOnLaunch', | ||
lastUpdateCheck: 'lastUpdateCheck', | ||
nodeModulesPath: 'nodeModulesPath' | ||
} ); | ||
|
||
module.exports = configKeys; |
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,57 @@ | ||
/* | ||
* Copyright (c) 2018-2019 João Pedro Martins Neves - All Rights Reserved. | ||
* | ||
* MergerJS (merger-js) is licensed under the MIT license, located in | ||
* the root of this project, under the name "LICENSE.md". | ||
* | ||
*/ | ||
|
||
const ImportType = require( '../enums/importType' ); | ||
|
||
class ParsedLine { | ||
|
||
constructor() { | ||
/** | ||
* @type { boolean } | ||
*/ | ||
this.isComment = null; | ||
|
||
/** | ||
* @type { boolean } | ||
*/ | ||
this.isDir = false; | ||
|
||
/** ImportType enum | ||
* @type { number } ImportType enum | ||
*/ | ||
this.importType = ImportType.Unknown; | ||
|
||
/** | ||
* @type { boolean } | ||
*/ | ||
this.forceInstall = false; | ||
|
||
/** | ||
* @type { string | null } | ||
*/ | ||
this.path = null; | ||
|
||
/** | ||
* @type { string | null } | ||
*/ | ||
this.directory = null; | ||
|
||
/** | ||
* @type { string | null } | ||
*/ | ||
this.branchName = null; | ||
|
||
/** | ||
* @type { boolean | null } | ||
**/ | ||
this.isGithubNewSyntax = null; | ||
} | ||
|
||
} | ||
|
||
module.exports = ParsedLine; |
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,14 @@ | ||
/* | ||
* Copyright (c) 2018-2019 João Pedro Martins Neves - All Rights Reserved. | ||
* | ||
* MergerJS (merger-js) is licensed under the MIT license, located in | ||
* the root of this project, under the name "LICENSE.md". | ||
* | ||
*/ | ||
|
||
const promptResponseType = Object.freeze( { | ||
Afirmative: 'Yes', | ||
Negative: 'No' | ||
} ); | ||
|
||
module.exports = promptResponseType; |
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,134 @@ | ||
/* | ||
* Copyright (c) 2018-2019 João Pedro Martins Neves - All Rights Reserved. | ||
* | ||
* MergerJS (merger-js) is licensed under the MIT license, located in | ||
* the root of this project, under the name "LICENSE.md". | ||
* | ||
*/ | ||
|
||
const Utils = require( '../utils' ); | ||
const TokenType = require( '../../enums/tokenType' ); | ||
const ImportType = require( '../../enums/importType' ); | ||
const ParsedLine = require( '../../models/parsedLineModel' ); | ||
|
||
class ImportLineParser { | ||
|
||
constructor() { | ||
throw new Error( 'Can not intantiate a static class' ); | ||
} | ||
|
||
/** | ||
* | ||
* @param { string } line | ||
* | ||
* @return { ParsedLine } | ||
*/ | ||
static parse( line ) { | ||
const parsedLine = new ParsedLine(); | ||
parsedLine.isComment = line.trimStart().startsWith( '//' ); | ||
|
||
line = line.replace( /\s/g, '' ); | ||
|
||
if ( !parsedLine.isComment ) { | ||
return parsedLine; | ||
} | ||
|
||
// #region IMPORT FROM RELATIVE PATH OR DIRECTORY | ||
|
||
if ( line.startsWith( TokenType.importPath, 2 ) || line.startsWith( TokenType.importPath_simbol, 2 ) ) { | ||
parsedLine.importType = ImportType.RelativePath; | ||
line = Utils.removeImportFromInput( line ); | ||
|
||
// #endregion IMPORT FROM RELATIVE PATH OR DIRECTORY | ||
|
||
// #region IMPORT FROM node_modules | ||
|
||
} else if ( line.startsWith( TokenType.importNodeModules, 2 ) || line.startsWith( TokenType.importNodeModules_simbol, 2 ) ) { | ||
parsedLine.importType = ImportType.NodeModules; | ||
line = Utils.removeImportFromInput( line ); | ||
|
||
// #endregion IMPORT FROM node_modules | ||
|
||
// #region IMPORT FROM AN URL | ||
|
||
} else if ( line.startsWith( TokenType.importUrl, 2 ) || line.startsWith( TokenType.importUrl_simbol, 2 ) || line.startsWith( TokenType.doubleImportUrl_simbol, 2 ) ) { | ||
parsedLine.forceInstall = line.startsWith( TokenType.doubleImportUrl_simbol, 2 ); | ||
line = Utils.removeImportFromInput( line ); | ||
|
||
// #region GITHUB SYNTAX DEFENITION COMMENTS | ||
|
||
// SINTAX: | ||
// // %import<<GH::{branch} '{user}/{repo}/{pathToFile}.js' | ||
// // %import<<GH::{branch}<<DIR '{user}/{repo}/{pathToFile}.js' | ||
// // %import<<GH::master<<DIR '{user}/{repo}/{pathToFile}.js' | ||
// DEPRECATED SYNTAX: // %import<<GH '{user}/{repo}/{branch}/{pathToFile}.js' | ||
|
||
// #endregion GITHUB SYNTAX DEFENITION COMMENTS | ||
|
||
// #region IMPORT FROM GITHUB | ||
|
||
if ( line.startsWith( TokenType.push_gh ) || | ||
line.startsWith( TokenType.push_GH ) || | ||
line.startsWith( TokenType.push_github ) || | ||
line.startsWith( TokenType.push_GITHUB ) | ||
) { | ||
parsedLine.importType = ImportType.GitHub; | ||
parsedLine.branchName = 'master'; | ||
|
||
line = Utils.removeGithubTokenFromImport( line ); | ||
|
||
if ( line.startsWith( '::' ) ) { | ||
parsedLine.branchName = ''; | ||
line = line.replace( /::/g, '' ); | ||
|
||
for ( let i = 0; i < line.length; ++i ) { | ||
if ( line[i] === '<' || line[i] === "'" || line[i] === ' ' ) | ||
break; | ||
|
||
parsedLine.branchName += line[i]; | ||
} | ||
|
||
parsedLine.isGithubNewSyntax = true; | ||
line = line.substring( parsedLine.branchName.length ); | ||
|
||
} else { | ||
parsedLine.isGithubNewSyntax = false; | ||
} | ||
|
||
|
||
// #endregion IMPORT FROM GITHUB | ||
|
||
// #region IMPORT FROM A SPECIFIC URL | ||
|
||
} else { | ||
parsedLine.importType = ImportType.SpecificURL; | ||
} | ||
|
||
// #endregion IMPORT FROM A SPECIFIC URL | ||
|
||
// #endregion IMPORT FROM AN URL | ||
|
||
} else { | ||
parsedLine.importType = ImportType.Unknown; | ||
} | ||
|
||
parsedLine.isDir = ImportLineParser.__pathIsDir( line ); | ||
|
||
if ( parsedLine.isDir ) { | ||
line = Utils.removeDirTokenFromImport( line ); | ||
} | ||
|
||
parsedLine.path = Utils.cleanImportFileInput( line ); | ||
return parsedLine; | ||
} | ||
|
||
static __pathIsDir( line ) { | ||
return line.startsWith( TokenType.push_dir ) || | ||
line.startsWith( TokenType.push_DIR ) || | ||
line.startsWith( TokenType.push_directory ) || | ||
line.startsWith( TokenType.push_DIRECTORY ); | ||
} | ||
|
||
} | ||
|
||
module.exports = ImportLineParser; |
Oops, something went wrong.