Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
Bertrand PINEL
ember-aws-ehipster
Commits
c5ba9d52
Commit
c5ba9d52
authored
Nov 25, 2018
by
Bertrand PINEL
Browse files
Add new default blueprint for detecting proxy flag
parent
6bb5bf07
Changes
4
Hide whitespace changes
Inline
Side-by-side
README.md
View file @
c5ba9d52
ember-aws-ehipster
==============================================================================
[Short description of the addon.]
This addon simplify the generation of code for model build with JDL Studio https://start.jhipster.tech/jdl-studio/
It also guide you to set up a JSON-API server on top of AWS API Gateway, Lambda and DynamoDB.
Installation
------------------------------------------------------------------------------
...
...
@@ -14,8 +16,14 @@ ember install ember-aws-ehipster
Usage
------------------------------------------------------------------------------
[Longer description of how to use the addon in apps.]
For generating a application, first use the standard command :
ember new test-ember-aws-ehipster --no-welcome
cd test-ember-aws-ehipster
ember install ember-aws-ehipster
Then generate a few entity through provided blueprints using the same syntax as the model blueprint :
ember g entity-factory blog title:string content:string order:number isVisible:boolean
ember g entity-factory post title:string content:string order:number visible:boolean
Contributing
------------------------------------------------------------------------------
...
...
blueprints/ember-aws-ehipster/index.js
0 → 100644
View file @
c5ba9d52
const
EOL
=
require
(
'
os
'
).
EOL
;
const
path
=
require
(
'
path
'
);
const
fs
=
require
(
'
fs
'
);
/* eslint-env node */
module
.
exports
=
{
description
:
''
,
normalizeEntityName
()
{},
// no argument
// locals(options) {
// // Return custom template variables here.
// return {
// foo: options.entity.options.foo
// };
// }
afterInstall
(
options
)
{
// Perform extra work here.
// Add proxy check to config/environment.js
let
configPath
=
(
options
.
dummy
)
?
"
tests/dummy/config/environment.js
"
:
"
config/environment.js
"
;
let
proxy
=
"
\n
function usingProxy() {
\n
"
+
"
\t
var usingProxyArg = !!process.argv.filter(function (arg) {
\n
"
+
"
\t\t
return arg.indexOf('--proxy') === 0 || arg.indexOf('-pr') === 0 || arg.indexOf('-pxy') === 0;
\n
"
+
"
\t
}).length;
\n\n
"
+
"
\t
var hasGeneratedProxies = false;
\n
"
+
"
\t
var proxiesDir = process.env.PWD + '/server/proxies';
\n
"
+
"
\t
try {
\n
"
+
"
\t\t
fs.lstatSync(proxiesDir);
\n
"
+
"
\t\t
hasGeneratedProxies = true;
\n
"
+
"
\t
} catch (e) {}
\n\n
"
+
"
\t
return usingProxyArg || hasGeneratedProxies;
\n
}
\n
"
;
addLineToFile
(
this
,
configPath
,
/'use strict';/
,
proxy
);
addLineToFile
(
this
,
configPath
,
/when it is created/
,
"
\t\t
proxy: usingProxy(),
"
);
}
};
function
addLineToFile
(
ctx
,
filePath
,
markerString
,
addedLine
)
{
let
fileContents
=
fs
.
readFileSync
(
filePath
,
'
utf-8
'
);
if
(
fileContents
.
indexOf
(
addedLine
)
===
-
1
)
{
ctx
.
ui
.
writeLine
(
"
\t
Add line
"
+
addedLine
+
"
to file
"
+
filePath
);
fileContents
=
fileContents
.
replace
(
markerString
,
[
'
$&
'
,
addedLine
,
].
join
(
'
\n
'
));
}
if
(
fileContents
.
indexOf
(
addedLine
)
===
-
1
)
{
ctx
.
ui
.
writeWarnLine
(
'
Unable to update
'
+
filePath
+
'
. You should update this file manually.
'
);
}
else
{
fs
.
writeFileSync
(
filePath
,
fileContents
,
'
utf-8
'
);
}
}
blueprints/entity-factory/index.js
View file @
c5ba9d52
...
...
@@ -161,7 +161,8 @@ module.exports = {
// Complete /mirage/config.js
let
mirageConfigPath
=
(
options
.
dummy
)
?
"
tests/dummy/mirage/config.js
"
:
"
mirage/config.js
"
;
let
configLine
=
"
\t\t
this.get('/
"
+
inflection
.
pluralize
(
entityName
)
+
"
', '
"
+
inflection
.
pluralize
(
entityName
)
+
"
');
"
let
configLine
=
"
\t\t
this.get('/
"
+
inflection
.
pluralize
(
entityName
)
+
"
', '
"
+
inflection
.
pluralize
(
entityName
)
+
"
');
\n
"
+
"
\t\t
this.post('/
"
+
inflection
.
pluralize
(
entityName
)
+
"
');
"
;
if
(
!
fs
.
existsSync
(
mirageConfigPath
))
{
this
.
ui
.
writeLine
(
"
Creating file
"
+
mirageConfigPath
);
let
configContent
=
"
import ENV from './../config/environment';
\n
"
+
...
...
@@ -171,8 +172,7 @@ module.exports = {
"
\t\t
this.passthrough();
\n\t
}
\n
}
\n
"
;
fs
.
writeFileSync
(
mirageConfigPath
,
configContent
,
'
utf-8
'
,
'
w+
'
);
}
else
{
//addLineToFile(this, mirageConfigPath, /this\.namespace = \'\';/, configLine);
addLineToFile
(
this
,
mirageConfigPath
,
/if
\(
ENV
\.
APP
\.
proxy
\)
{/
,
configLine
);
addLineToFile
(
this
,
mirageConfigPath
,
/if
\(
!ENV
\.
APP
\.
proxy
\)
{/
,
configLine
);
}
// Add route in router.js for the entity page
...
...
package.json
View file @
c5ba9d52
{
"name"
:
"ember-aws-ehipster"
,
"version"
:
"0.
0.6
"
,
"version"
:
"0.
1.1
"
,
"description"
:
"The default blueprint for ember-cli addons."
,
"keywords"
:
[
"ember-addon"
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment