backend-manager 5.0.61 → 5.0.63

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.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "backend-manager",
3
- "version": "5.0.61",
3
+ "version": "5.0.63",
4
4
  "description": "Quick tools for developing Firebase functions",
5
5
  "main": "src/manager/index.js",
6
6
  "bin": {
@@ -12,7 +12,7 @@ class GitignoreTest extends BaseTest {
12
12
  }
13
13
 
14
14
  async run() {
15
- const gitignorePath = `${this.self.firebaseProjectPath}/functions/.gitignore`;
15
+ const gitignorePath = `${this.self.firebaseProjectPath}/.gitignore`;
16
16
  const existingContent = jetpack.read(gitignorePath);
17
17
 
18
18
  if (!existingContent) {
@@ -86,7 +86,7 @@ class GitignoreTest extends BaseTest {
86
86
  }
87
87
 
88
88
  async fix() {
89
- const gitignorePath = `${this.self.firebaseProjectPath}/functions/.gitignore`;
89
+ const gitignorePath = `${this.self.firebaseProjectPath}/.gitignore`;
90
90
  const templatePath = path.resolve(__dirname, '../../../../templates/_.gitignore');
91
91
 
92
92
  const templateContent = jetpack.read(templatePath);
@@ -40,7 +40,7 @@ class SetupCommand extends BaseCommand {
40
40
  self.remoteconfigJSON = loadJSON(`${self.firebaseProjectPath}/functions/remoteconfig.template.json`);
41
41
  self.projectPackage = loadJSON(`${self.firebaseProjectPath}/package.json`);
42
42
  self.bemConfigJSON = loadJSON(`${self.firebaseProjectPath}/functions/backend-manager-config.json`);
43
- self.gitignore = jetpack.read(`${self.firebaseProjectPath}/functions/.gitignore`) || '';
43
+ self.gitignore = jetpack.read(`${self.firebaseProjectPath}/.gitignore`) || '';
44
44
 
45
45
  // Check if package exists
46
46
  if (!hasContent(self.package)) {
@@ -165,7 +165,7 @@ class SetupCommand extends BaseCommand {
165
165
  timeout: 30000,
166
166
  response: 'json',
167
167
  query: {
168
- backendManagerKey: self?.runtimeConfigJSON?.backend_manager?.key,
168
+ backendManagerKey: process.env.BACKEND_MANAGER_KEY,
169
169
  },
170
170
  })
171
171
  .then(json => json)
@@ -1,9 +0,0 @@
1
- {
2
- backend_manager: {
3
- key: '',
4
- namespace: '',
5
- },
6
- github: {
7
- key: '',
8
- },
9
- }
@@ -1,224 +0,0 @@
1
- const { expect } = require('chai');
2
- const sinon = require('sinon');
3
- const path = require('path');
4
-
5
- // Import the Main CLI class
6
- const Main = require('../src/cli/cli');
7
-
8
- // Import individual commands
9
- const commands = require('../src/cli/commands');
10
-
11
- describe('CLI Commands', function() {
12
- let main;
13
- let consoleLogStub;
14
- let processExitStub;
15
-
16
- beforeEach(function() {
17
- // Create a new Main instance for each test
18
- main = new Main();
19
-
20
- // Stub console.log to capture output
21
- consoleLogStub = sinon.stub(console, 'log');
22
-
23
- // Stub process.exit to prevent tests from exiting
24
- processExitStub = sinon.stub(process, 'exit');
25
- });
26
-
27
- afterEach(function() {
28
- // Restore stubs
29
- consoleLogStub.restore();
30
- processExitStub.restore();
31
- });
32
-
33
- describe('VersionCommand', function() {
34
- it('should display the correct version', async function() {
35
- const versionCmd = new commands.VersionCommand(main);
36
- main.packageJSON = { version: '5.0.3' };
37
-
38
- await versionCmd.execute();
39
-
40
- expect(consoleLogStub.calledWith('Backend manager is version: 5.0.3')).to.be.true;
41
- });
42
- });
43
-
44
- describe('CwdCommand', function() {
45
- it('should display the current working directory', async function() {
46
- const cwdCmd = new commands.CwdCommand(main);
47
- main.firebaseProjectPath = '/test/path';
48
-
49
- await cwdCmd.execute();
50
-
51
- // Check that console.log was called with two arguments: 'cwd: ' and the path
52
- expect(consoleLogStub.calledOnce).to.be.true;
53
- const callArgs = consoleLogStub.getCall(0).args;
54
- expect(callArgs[0]).to.equal('cwd: ');
55
- expect(callArgs[1]).to.equal('/test/path');
56
- });
57
- });
58
-
59
- describe('ClearCommand', function() {
60
- it('should clear the console', async function() {
61
- const clearCmd = new commands.ClearCommand(main);
62
- const writeSpy = sinon.spy(process.stdout, 'write');
63
- const clearSpy = sinon.spy(console, 'clear');
64
-
65
- await clearCmd.execute();
66
-
67
- expect(writeSpy.called).to.be.true;
68
- expect(clearSpy.called).to.be.true;
69
-
70
- writeSpy.restore();
71
- clearSpy.restore();
72
- });
73
- });
74
-
75
- describe('Main CLI process method', function() {
76
- it('should handle version flag correctly', async function() {
77
- main.packageJSON = { version: '5.0.3' };
78
-
79
- await main.process(['version']);
80
-
81
- expect(consoleLogStub.calledWith('Backend manager is version: 5.0.3')).to.be.true;
82
- });
83
-
84
- it('should handle cwd flag correctly', async function() {
85
- await main.process(['cwd']);
86
-
87
- expect(consoleLogStub.calledWithMatch('cwd: ')).to.be.true;
88
- });
89
-
90
- it('should parse multiple arguments correctly', async function() {
91
- main.packageJSON = { version: '5.0.3' };
92
-
93
- await main.process(['v']);
94
-
95
- expect(main.options.v).to.be.true;
96
- expect(consoleLogStub.calledWith('Backend manager is version: 5.0.3')).to.be.true;
97
- });
98
- });
99
-
100
- describe('InstallCommand', function() {
101
- let execStub;
102
-
103
- beforeEach(function() {
104
- const powertools = require('node-powertools');
105
- execStub = sinon.stub(powertools, 'execute').resolves();
106
- });
107
-
108
- afterEach(function() {
109
- execStub.restore();
110
- });
111
-
112
- it('should uninstall and install local backend-manager', async function() {
113
- const installCmd = new commands.InstallCommand(main);
114
-
115
- await installCmd.execute('local');
116
-
117
- expect(execStub.calledWith('npm uninstall backend-manager')).to.be.true;
118
- expect(execStub.calledWithMatch(/npm install.*backend-manager --save-dev/)).to.be.true;
119
- });
120
-
121
- it('should uninstall and install live backend-manager', async function() {
122
- const installCmd = new commands.InstallCommand(main);
123
-
124
- await installCmd.execute('live');
125
-
126
- expect(execStub.calledWith('npm uninstall backend-manager')).to.be.true;
127
- expect(execStub.calledWith('npm i backend-manager@latest')).to.be.true;
128
- });
129
- });
130
-
131
- describe('CleanCommand', function() {
132
- let execStub;
133
-
134
- beforeEach(function() {
135
- const powertools = require('node-powertools');
136
- execStub = sinon.stub(powertools, 'execute').resolves();
137
- });
138
-
139
- afterEach(function() {
140
- execStub.restore();
141
- });
142
-
143
- it('should execute the clean npm script', async function() {
144
- const cleanCmd = new commands.CleanCommand(main);
145
-
146
- await cleanCmd.execute();
147
-
148
- expect(execStub.calledWithMatch(/rm -fr node_modules/)).to.be.true;
149
- });
150
- });
151
-
152
- describe('ConfigCommand', function() {
153
- let execStub;
154
- let originalRequire;
155
-
156
- beforeEach(function() {
157
- const powertools = require('node-powertools');
158
- execStub = sinon.stub(powertools, 'execute').resolves();
159
-
160
- // Mock require for config file - simplified approach
161
- const Module = require('module');
162
- originalRequire = Module.prototype.require;
163
- sinon.stub(Module.prototype, 'require').callsFake(function(id) {
164
- if (id.includes('.runtimeconfig.json')) {
165
- return { test: 'config' };
166
- }
167
- return originalRequire.apply(this, arguments);
168
- });
169
- });
170
-
171
- afterEach(function() {
172
- execStub.restore();
173
-
174
- // Restore original require
175
- const Module = require('module');
176
- Module.prototype.require.restore();
177
- });
178
-
179
- it('should get firebase config', async function() {
180
- const configCmd = new commands.ConfigCommand(main);
181
- main.firebaseProjectPath = '/test/project';
182
-
183
- const config = await configCmd.get();
184
-
185
- expect(execStub.calledWithMatch(/firebase functions:config:get/)).to.be.true;
186
- expect(config).to.deep.equal({ test: 'config' });
187
- });
188
- });
189
-
190
- describe('IndexesCommand', function() {
191
- let execStub;
192
- let requireStub;
193
-
194
- beforeEach(function() {
195
- const powertools = require('node-powertools');
196
- execStub = sinon.stub(powertools, 'execute').resolves();
197
-
198
- // Mock require for indexes file - simplified approach
199
- const Module = require('module');
200
- const originalRequire = Module.prototype.require;
201
- requireStub = sinon.stub(Module.prototype, 'require').callsFake(function(id) {
202
- if (id.includes('firestore.indexes.json')) {
203
- return { indexes: [] };
204
- }
205
- return originalRequire.apply(this, arguments);
206
- });
207
- });
208
-
209
- afterEach(function() {
210
- execStub.restore();
211
- requireStub.restore();
212
- });
213
-
214
- it('should get firestore indexes', async function() {
215
- const indexesCmd = new commands.IndexesCommand(main);
216
- main.firebaseProjectPath = '/test/project';
217
-
218
- const indexes = await indexesCmd.get();
219
-
220
- expect(execStub.calledWithMatch(/firebase firestore:indexes/)).to.be.true;
221
- expect(indexes).to.deep.equal({ indexes: [] });
222
- });
223
- });
224
- });