MCPcopy Create free account
hub / github.com/firebase/firebase-tools / applyTarget

Method applyTarget

src/rc.ts:117–148  ·  view source on GitHub ↗
(project: string, type: string, targetName: string, resources: string | string[])

Source from the content-addressed store, hash-verified

115 }
116
117 applyTarget(project: string, type: string, targetName: string, resources: string | string[]) {
118 if (!TARGET_TYPES[type]) {
119 throw new FirebaseError(
120 `Unrecognized target type ${clc.bold(type)}. Must be one of ${Object.keys(
121 TARGET_TYPES,
122 ).join(", ")}`,
123 );
124 }
125
126 if (typeof resources === "string") {
127 resources = [resources];
128 }
129
130 const changed: { resource: string; target: string }[] = [];
131
132 // remove resources from existing targets
133 for (const resource of resources) {
134 const cur = this.findTarget(project, type, resource);
135 if (cur && cur !== targetName) {
136 this.unsetTargetResource(project, type, cur, resource);
137 changed.push({ resource: resource, target: cur });
138 }
139 }
140
141 // apply resources to new target
142 const existing = this.target(project, type, targetName);
143 const list = Array.from(new Set(existing.concat(resources))).sort();
144 this.set(["targets", project, type, targetName], list);
145
146 this.save();
147 return changed;
148 }
149
150 removeTarget(project: string, type: string, resource: string): string | null {
151 const name = this.findTarget(project, type, resource);

Callers 3

rc.spec.tsFile · 0.80
target-apply.tsFile · 0.80
config.spec.tsFile · 0.80

Calls 6

findTargetMethod · 0.95
unsetTargetResourceMethod · 0.95
targetMethod · 0.95
setMethod · 0.95
saveMethod · 0.95
fromMethod · 0.80

Tested by

no test coverage detected