@leverege/build-tools 2.17.0 → 2.17.2

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.
Binary file
@@ -20,23 +20,37 @@ let TARGET = _zx.argv._[0];
20
20
  let exited = false;
21
21
  const SECRETS_DIR = 'secrets';
22
22
  const EXIT_EVENTS = ['SIGINT', 'exit', 'uncaughtException', 'unhandledRejection'];
23
- const [firebaserc, firebaseJson] = await Promise.all([_zx.fs.exists(_zx.path.join(process.cwd(), '.firebaserc')), _zx.fs.exists(_zx.path.join(process.cwd(), 'firebase.json'))]);
23
+ const [firebaserc, firebaseJson, hasLocalConfig] = await Promise.all([_zx.fs.exists(_zx.path.join(process.cwd(), '.firebaserc')), _zx.fs.exists(_zx.path.join(process.cwd(), 'firebase.json')), _zx.fs.exists(_zx.path.join(process.cwd(), SECRETS_DIR, 'local.env'))]);
24
24
 
25
- if (!firebaserc) {
26
- console.log(_zx.chalk.red('No .firebaserc file found. Make sure that you are executing firebaseDeploy from within a firebase project directory.'));
27
- }
25
+ if (!hasLocalConfig) {
26
+ if (!firebaserc) {
27
+ console.log(_zx.chalk.red('No .firebaserc file found. Make sure that you are executing firebaseDeploy from within a firebase project directory.'));
28
+ }
28
29
 
29
- if (!firebaseJson) {
30
- console.log(_zx.chalk.red('No firebase.json file found. Make sure that you are executing firebaseDeploy from within a firebase project directory.'));
31
- }
30
+ if (!firebaseJson) {
31
+ console.log(_zx.chalk.red('No firebase.json file found. Make sure that you are executing firebaseDeploy from within a firebase project directory.'));
32
+ }
32
33
 
33
- if (!firebaserc || !firebaseJson) {
34
- process.exit();
34
+ if (!firebaserc || !firebaseJson) {
35
+ process.exit();
36
+ }
35
37
  }
36
38
 
37
- const firebasercContent = JSON.parse(await _zx.fs.readFile(_zx.path.join(process.cwd(), '.firebaserc'), {
39
+ const firebasercContent = firebaserc ? JSON.parse(await _zx.fs.readFile(_zx.path.join(process.cwd(), '.firebaserc'), {
38
40
  encoding: 'utf-8'
39
- }));
41
+ })) : {
42
+ targets: {}
43
+ };
44
+ console.log(firebaserc, firebasercContent);
45
+ const defaultTargets = {};
46
+
47
+ if (hasLocalConfig) {
48
+ defaultTargets.local = {
49
+ siteId: 'local',
50
+ alias: 'local'
51
+ };
52
+ }
53
+
40
54
  const targets = Object.entries(firebasercContent.targets).reduce((prev, [projectId, config]) => {
41
55
  Object.entries(config.hosting).forEach(([siteId, aliases]) => {
42
56
  aliases.forEach(alias => {
@@ -48,7 +62,7 @@ const targets = Object.entries(firebasercContent.targets).reduce((prev, [project
48
62
  });
49
63
  });
50
64
  return prev;
51
- }, {});
65
+ }, defaultTargets);
52
66
 
53
67
  if (!TARGET) {
54
68
  const {
Binary file
@@ -20,23 +20,37 @@ let TARGET = _zx.argv._[0];
20
20
  let exited = false;
21
21
  const SECRETS_DIR = 'secrets';
22
22
  const EXIT_EVENTS = ['SIGINT', 'exit', 'uncaughtException', 'unhandledRejection'];
23
- const [firebaserc, firebaseJson] = await Promise.all([_zx.fs.exists(_zx.path.join(process.cwd(), '.firebaserc')), _zx.fs.exists(_zx.path.join(process.cwd(), 'firebase.json'))]);
23
+ const [firebaserc, firebaseJson, hasLocalConfig] = await Promise.all([_zx.fs.exists(_zx.path.join(process.cwd(), '.firebaserc')), _zx.fs.exists(_zx.path.join(process.cwd(), 'firebase.json')), _zx.fs.exists(_zx.path.join(process.cwd(), SECRETS_DIR, 'local.env'))]);
24
24
 
25
- if (!firebaserc) {
26
- console.log(_zx.chalk.red('No .firebaserc file found. Make sure that you are executing firebaseDeploy from within a firebase project directory.'));
27
- }
25
+ if (!hasLocalConfig) {
26
+ if (!firebaserc) {
27
+ console.log(_zx.chalk.red('No .firebaserc file found. Make sure that you are executing firebaseDeploy from within a firebase project directory.'));
28
+ }
28
29
 
29
- if (!firebaseJson) {
30
- console.log(_zx.chalk.red('No firebase.json file found. Make sure that you are executing firebaseDeploy from within a firebase project directory.'));
31
- }
30
+ if (!firebaseJson) {
31
+ console.log(_zx.chalk.red('No firebase.json file found. Make sure that you are executing firebaseDeploy from within a firebase project directory.'));
32
+ }
32
33
 
33
- if (!firebaserc || !firebaseJson) {
34
- process.exit();
34
+ if (!firebaserc || !firebaseJson) {
35
+ process.exit();
36
+ }
35
37
  }
36
38
 
37
- const firebasercContent = JSON.parse(await _zx.fs.readFile(_zx.path.join(process.cwd(), '.firebaserc'), {
39
+ const firebasercContent = firebaserc ? JSON.parse(await _zx.fs.readFile(_zx.path.join(process.cwd(), '.firebaserc'), {
38
40
  encoding: 'utf-8'
39
- }));
41
+ })) : {
42
+ targets: {}
43
+ };
44
+ console.log(firebaserc, firebasercContent);
45
+ const defaultTargets = {};
46
+
47
+ if (hasLocalConfig) {
48
+ defaultTargets.local = {
49
+ siteId: 'local',
50
+ alias: 'local'
51
+ };
52
+ }
53
+
40
54
  const targets = Object.entries(firebasercContent.targets).reduce((prev, [projectId, config]) => {
41
55
  Object.entries(config.hosting).forEach(([siteId, aliases]) => {
42
56
  aliases.forEach(alias => {
@@ -48,7 +62,7 @@ const targets = Object.entries(firebasercContent.targets).reduce((prev, [project
48
62
  });
49
63
  });
50
64
  return prev;
51
- }, {});
65
+ }, defaultTargets);
52
66
 
53
67
  if (!TARGET) {
54
68
  const {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@leverege/build-tools",
3
- "version": "2.17.0",
3
+ "version": "2.17.2",
4
4
  "description": "A collection of build / support tools for Leverege developers",
5
5
  "main": "index.js",
6
6
  "repository": {
@@ -18,25 +18,41 @@ const EXIT_EVENTS = [ 'SIGINT', 'exit', 'uncaughtException', 'unhandledRejection
18
18
 
19
19
  const [
20
20
  firebaserc,
21
- firebaseJson
21
+ firebaseJson,
22
+ hasLocalConfig
22
23
  ] = await Promise.all( [
23
24
  fs.exists( path.join( process.cwd(), '.firebaserc' ) ),
24
- fs.exists( path.join( process.cwd(), 'firebase.json' ) )
25
+ fs.exists( path.join( process.cwd(), 'firebase.json' ) ),
26
+ fs.exists( path.join( process.cwd(), SECRETS_DIR, 'local.env' ) )
25
27
  ] )
26
28
 
27
- if ( !firebaserc ) {
28
- console.log( chalk.red( 'No .firebaserc file found. Make sure that you are executing firebaseDeploy from within a firebase project directory.' ) )
29
+ if ( !hasLocalConfig ) {
30
+ if ( !firebaserc ) {
31
+ console.log( chalk.red( 'No .firebaserc file found. Make sure that you are executing firebaseDeploy from within a firebase project directory.' ) )
32
+ }
33
+
34
+ if ( !firebaseJson ) {
35
+ console.log( chalk.red( 'No firebase.json file found. Make sure that you are executing firebaseDeploy from within a firebase project directory.' ) )
36
+ }
37
+
38
+ if ( !firebaserc || !firebaseJson ) {
39
+ process.exit()
40
+ }
29
41
  }
30
42
 
31
- if ( !firebaseJson ) {
32
- console.log( chalk.red( 'No firebase.json file found. Make sure that you are executing firebaseDeploy from within a firebase project directory.' ) )
33
- }
43
+ const firebasercContent = firebaserc ?
44
+ JSON.parse( await fs.readFile( path.join( process.cwd(), '.firebaserc' ), { encoding : 'utf-8' } ) ) :
45
+ { targets : {} }
34
46
 
35
- if ( !firebaserc || !firebaseJson ) {
36
- process.exit()
37
- }
47
+ console.log( firebaserc, firebasercContent )
48
+ const defaultTargets = {}
38
49
 
39
- const firebasercContent = JSON.parse( await fs.readFile( path.join( process.cwd(), '.firebaserc' ), { encoding : 'utf-8' } ) )
50
+ if ( hasLocalConfig ) {
51
+ defaultTargets.local = {
52
+ siteId : 'local',
53
+ alias : 'local'
54
+ }
55
+ }
40
56
 
41
57
  const targets = Object
42
58
  .entries( firebasercContent.targets )
@@ -54,7 +70,7 @@ const targets = Object
54
70
  } )
55
71
 
56
72
  return prev
57
- }, {} )
73
+ }, defaultTargets )
58
74
 
59
75
  if ( !TARGET ) {
60
76
  const { targetEnv } = await prompt( {