Skip to content

Commit 7cf0804

Browse files
chore(lint): Clean up deploy stuff
1 parent a9eec3d commit 7cf0804

File tree

4 files changed

+35
-27
lines changed

4 files changed

+35
-27
lines changed

src/firestore/collection/collection.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ import { AngularFirestoreDocument } from '../document/document';
99
import { AngularFirestore } from '../firestore';
1010

1111
export function validateEventsArray(events?: DocumentChangeType[]) {
12-
if (!events || events!.length === 0) {
12+
if (!events || events.length === 0) {
1313
events = ['added', 'removed', 'modified'];
1414
}
1515
return events;
@@ -98,6 +98,7 @@ export class AngularFirestoreCollection<T= DocumentData> {
9898
* provided `idField` property name.
9999
*/
100100
valueChanges(): Observable<T[]>;
101+
// tslint:disable-next-line:unified-signatures
101102
valueChanges({}): Observable<T[]>;
102103
valueChanges<K extends string>(options: {idField: K}): Observable<(T & { [T in K]: string })[]>;
103104
valueChanges<K extends string>(options: {idField?: K} = {}): Observable<T[]> {
@@ -106,7 +107,7 @@ export class AngularFirestoreCollection<T= DocumentData> {
106107
map(actions => actions.payload.docs.map(a => {
107108
if (options.idField) {
108109
return {
109-
...a.data() as Object,
110+
...a.data() as {},
110111
...{ [options.idField]: a.id }
111112
} as T & { [T in K]: string };
112113
} else {

src/firestore/firestore.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -110,6 +110,7 @@ export class AngularFirestore {
110110
@Optional() @Inject(FIREBASE_APP_NAME) nameOrConfig: string|FirebaseAppConfig|null|undefined,
111111
@Optional() @Inject(ENABLE_PERSISTENCE) shouldEnablePersistence: boolean|null,
112112
@Optional() @Inject(SETTINGS) settings: Settings|null,
113+
// tslint:disable-next-line:ban-types
113114
@Inject(PLATFORM_ID) platformId: Object,
114115
zone: NgZone,
115116
@Optional() @Inject(PERSISTENCE_SETTINGS) persistenceSettings: PersistenceSettings|null,
@@ -149,8 +150,7 @@ export class AngularFirestore {
149150
* CollectionReference and an optional query function to narrow the result
150151
* set.
151152
*/
152-
collection<T>(path: string, queryFn?: QueryFn): AngularFirestoreCollection<T>;
153-
collection<T>(ref: CollectionReference, queryFn?: QueryFn): AngularFirestoreCollection<T>;
153+
collection<T>(path: string| CollectionReference, queryFn?: QueryFn): AngularFirestoreCollection<T>;
154154
collection<T>(pathOrRef: string | CollectionReference, queryFn?: QueryFn): AngularFirestoreCollection<T> {
155155
let collectionRef: CollectionReference;
156156
if (typeof pathOrRef === 'string') {

src/remote-config/remote-config.ts

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,16 @@ export const DEFAULTS = new InjectionToken<ConfigTemplate>('angularfire2.remoteC
1414

1515
export interface AngularFireRemoteConfig extends ɵPromiseProxy<remoteConfig.RemoteConfig> {
1616
}
17+
// TODO look into the types here, I don't like the anys
18+
const proxyAll = (observable: Observable<Parameter[]>, as: 'numbers' | 'booleans' | 'strings') => new Proxy(
19+
observable.pipe(mapToObject(as as any)), {
20+
get: (self, name: string) => self[name] || observable.pipe(
21+
map(all => all.find(p => p.key === name)),
22+
map(param => param ? param[AS_TO_FN[as]]() : STATIC_VALUES[as]),
23+
distinctUntilChanged()
24+
)
25+
}
26+
) as any;
1727

1828
// TODO export as implements Partial<...> so minor doesn't break us
1929
export class Value implements remoteConfig.Value {
@@ -266,13 +276,3 @@ export function mapToObject<T extends ConfigTemplate>(to: 'numbers' | 'booleans'
266276
);
267277
}
268278

269-
// TODO look into the types here, I don't like the anys
270-
const proxyAll = (observable: Observable<Parameter[]>, as: 'numbers' | 'booleans' | 'strings') => new Proxy(
271-
observable.pipe(mapToObject(as as any)), {
272-
get: (self, name: string) => self[name] || observable.pipe(
273-
map(all => all.find(p => p.key === name)),
274-
map(param => param ? param[AS_TO_FN[as]]() : STATIC_VALUES[as]),
275-
distinctUntilChanged()
276-
)
277-
}
278-
) as any;

src/schematics/deploy/actions.ts

Lines changed: 20 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ import { experimental } from '@angular-devkit/core';
99
import { SchematicsException } from '@angular-devkit/schematics';
1010
import { satisfies } from 'semver';
1111

12-
const escapeRegExp = (str: String) => str.replace(/[\-\[\]\/\{\}\(\)\*\+\?\.\\\^\$\|]/g, '\\$&');
12+
const escapeRegExp = (str: string) => str.replace(/[\-\[\]\/{}()*+?.\\^$|]/g, '\\$&');
1313

1414
const moveSync = (src: string, dest: string) => {
1515
copySync(src, dest);
@@ -30,7 +30,7 @@ const deployToHosting = (
3030
execSync(`open http://localhost:${port} || true`);
3131
}, 1500);
3232

33-
return firebaseTools.serve({ port, targets: ['hosting']}).then(() =>
33+
return firebaseTools.serve({ port, targets: ['hosting'] }).then(() =>
3434
require('inquirer').prompt({
3535
type: 'confirm',
3636
name: 'deployProject',
@@ -78,19 +78,24 @@ const getPackageJson = (context: BuilderContext, workspaceRoot: string) => {
7878
const npmList = execSync('npm ls || true').toString();
7979
Object.keys(dependencies).forEach((dependency: string) => {
8080
const npmLsMatch = npmList.match(` ${escapeRegExp(dependency)}@.+\\w`);
81-
if (npmLsMatch) { dependencies[dependency] = npmLsMatch[0].split(`${dependency}@`)[1]; }
81+
if (npmLsMatch) {
82+
dependencies[dependency] = npmLsMatch[0].split(`${dependency}@`)[1];
83+
}
8284
});
8385
Object.keys(devDependencies).forEach((devDependency: string) => {
8486
const npmLsMatch = npmList.match(` ${escapeRegExp(devDependency)}@.+\\w`);
85-
if (npmLsMatch) { devDependencies[devDependency] = npmLsMatch[0].split(`${devDependency}@`)[1]; }
87+
if (npmLsMatch) {
88+
devDependencies[devDependency] = npmLsMatch[0].split(`${devDependency}@`)[1];
89+
}
8690
});
8791
if (existsSync(join(workspaceRoot, 'angular.json'))) {
8892
const angularJson = JSON.parse(readFileSync(join(workspaceRoot, 'angular.json')).toString());
93+
// tslint:disable-next-line:no-non-null-assertion
8994
const server = angularJson.projects[context.target!.project].architect.server;
9095
const serverOptions = server && server.options;
9196
const externalDependencies = serverOptions && serverOptions.externalDependencies || [];
9297
const bundleDependencies = serverOptions && serverOptions.bundleDependencies;
93-
if (bundleDependencies == false) {
98+
if (bundleDependencies !== true) {
9499
if (existsSync(join(workspaceRoot, 'package.json'))) {
95100
const packageJson = JSON.parse(readFileSync(join(workspaceRoot, 'package.json')).toString());
96101
Object.keys(packageJson.dependencies).forEach((dependency: string) => {
@@ -100,7 +105,9 @@ const getPackageJson = (context: BuilderContext, workspaceRoot: string) => {
100105
} else {
101106
externalDependencies.forEach(externalDependency => {
102107
const npmLsMatch = npmList.match(` ${escapeRegExp(externalDependency)}@.+\\w`);
103-
if (npmLsMatch) { dependencies[externalDependency] = npmLsMatch[0].split(`${externalDependency}@`)[1]; }
108+
if (npmLsMatch) {
109+
dependencies[externalDependency] = npmLsMatch[0].split(`${externalDependency}@`)[1];
110+
}
104111
});
105112
}
106113
} // TODO should we throw?
@@ -177,7 +184,7 @@ export const deployToFunction = async (
177184
execSync(`open http://localhost:${port} || true`);
178185
}, 1500);
179186

180-
return firebaseTools.serve({ port, targets: ['hosting', 'functions']}).then(() =>
187+
return firebaseTools.serve({ port, targets: ['hosting', 'functions'] }).then(() =>
181188
require('inquirer').prompt({
182189
type: 'confirm',
183190
name: 'deployProject',
@@ -186,6 +193,7 @@ export const deployToFunction = async (
186193
).then(({ deployProject }: { deployProject: boolean }) => {
187194
if (deployProject) {
188195
return firebaseTools.deploy({
196+
// tslint:disable-next-line:no-non-null-assertion
189197
only: `hosting:${context.target!.project},functions:ssr`,
190198
cwd: workspaceRoot
191199
});
@@ -195,6 +203,7 @@ export const deployToFunction = async (
195203
});
196204
} else {
197205
return firebaseTools.deploy({
206+
// tslint:disable-next-line:no-non-null-assertion
198207
only: `hosting:${context.target!.project},functions:ssr`,
199208
cwd: workspaceRoot
200209
});
@@ -233,8 +242,6 @@ export default async function deploy(
233242
}
234243

235244
try {
236-
let success: { hosting: string };
237-
238245
const winston = require('winston');
239246
const tripleBeam = require('triple-beam');
240247

@@ -243,22 +250,22 @@ export default async function deploy(
243250
level: 'info',
244251
format: winston.format.printf((info) =>
245252
[info.message, ...(info[tripleBeam.SPLAT] || [])]
246-
.filter((chunk) => typeof chunk == 'string')
253+
.filter((chunk) => typeof chunk === 'string')
247254
.join(' ')
248-
),
255+
)
249256
})
250257
);
251258

252259
if (ssr) {
253-
success = await deployToFunction(
260+
await deployToFunction(
254261
firebaseTools,
255262
context,
256263
context.workspaceRoot,
257264
projectTargets,
258265
preview
259266
);
260267
} else {
261-
success = await deployToHosting(
268+
await deployToHosting(
262269
firebaseTools,
263270
context,
264271
context.workspaceRoot,

0 commit comments

Comments
 (0)