UNPKG

1.56 kBJavaScriptView Raw
1'use strict';
2
3const boxen = require('boxen');
4const chalk = require('chalk');
5const isStandaloneExecutable = require('../lib/utils/isStandaloneExecutable');
6
7const isWindows = process.platform === 'win32';
8
9const truthyStr = val => val && !['0', 'false', 'f', 'n', 'no'].includes(val.toLowerCase());
10const { CI, ADBLOCK, SILENT } = process.env;
11if (!truthyStr(CI) && !truthyStr(ADBLOCK) && !truthyStr(SILENT)) {
12 const messageTokens = ['Serverless Framework successfully installed!'];
13 if (isStandaloneExecutable && !isWindows) {
14 messageTokens.push(
15 'To start your first project, please open another terminal and run “serverless”.',
16 'You can uninstall at anytime by running “serverless uninstall”.'
17 );
18 } else {
19 messageTokens.push("To start your first project run 'serverless'.");
20 }
21 const message = messageTokens.join('\n\n');
22 process.stdout.write(
23 `${
24 isStandaloneExecutable && isWindows
25 ? message
26 : boxen(chalk.yellow(message), {
27 padding: 1,
28 margin: 1,
29 borderColor: 'yellow',
30 })
31 }\n`
32 );
33}
34
35try {
36 const Serverless = require('../lib/Serverless');
37 const serverless = new Serverless();
38
39 serverless
40 .init()
41 .then(() => serverless.utils.logStat(serverless, 'install'))
42 .catch(() => {});
43} catch (error) {
44 // Ignore any eventual errors.
45 // Package when installed globally may be installed in uncommon user contexts,
46 // that may lead to fs access related crashes
47 // when e.g. trying to access user's .serverlessrc config
48}