Skip to content

Commit c4f955a

Browse files
committed
feat: replace projectName with serviceName for consistency
The term "project" is being used a lot in the Twilio CLI and causes a lot of confusion BREAKING CHANGE: projectName is no longer valid and serviceName has to be used instead fix twilio-labs/serverless-toolkit#17
1 parent d0e404c commit c4f955a

File tree

5 files changed

+29
-31
lines changed

5 files changed

+29
-31
lines changed

Diff for: README.md

+9-9
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66

77
## ⚠️ **IMPORTANT**
88

9-
This is a module for an experimental API that is still in preview mode.
9+
This is a module for an experimental API that is still in preview mode.
1010

1111
You won't be able to use this library unless you have been granted prior access to the underlying API.
1212

@@ -40,7 +40,7 @@ const TwilioServerlessApiClient = require('@twilio-labs/serverless-api');
4040

4141
const client = new TwilioServerlessApiClient({
4242
accountSid: '...',
43-
authToken: '...'
43+
authToken: '...',
4444
});
4545

4646
client.on('status-update', evt => {
@@ -52,12 +52,12 @@ const result = await client.deployLocalProject({
5252
envPath: '...',
5353
accountSid: '...',
5454
authToken: '...',
55-
env: { },
55+
env: {},
5656
pkgJson: {},
57-
projectName: 'serverless-example',
57+
serviceName: 'serverless-example',
5858
functionsEnv: 'dev',
5959
assetsFolderName: 'static',
60-
functionsFolderName: 'src'
60+
functionsFolderName: 'src',
6161
});
6262
```
6363

@@ -87,9 +87,9 @@ Nested folder structures will result in nested routes.
8787

8888
Deploys a set of functions, assets, variables and dependencies specified in deployConfig. Functions & assets can either be paths to the local filesystem or Buffer instances allowing you to dynamically upload even without a file system.
8989

90-
Unless a deployConfig. serviceSid is specified, it will try to create one. If a service with the name deployConfig.projectName already exists, it will throw an error. You can make it use the existing service by setting overrideExistingService to true.
90+
Unless a deployConfig. serviceSid is specified, it will try to create one. If a service with the name deployConfig.serviceName already exists, it will throw an error. You can make it use the existing service by setting overrideExistingService to true.
9191

92-
Updates to the deployment will be emitted as events to status-update.
92+
Updates to the deployment will be emitted as events to status-update.
9393

9494
[More in the Docs](https://serverless-api.twilio-labs.com/classes/_twilio_labs_serverless_api.twilioserverlessapiclient.html#deployproject)
9595

@@ -119,7 +119,7 @@ const api = require('@twilio-labs/serverless-api/dist/api');
119119
const utils = require('@twilio-labs/serverless-api/dist/utils');
120120
```
121121

122-
## Contributing
122+
## Contributing
123123

124124
This project welcomes contributions from the community. Please see the [`CONTRIBUTING.md`](CONTRIBUTING.md) file for more details.
125125

@@ -145,4 +145,4 @@ This project follows the [all-contributors](https://github.com/all-contributors/
145145

146146
## License
147147

148-
MIT
148+
MIT

Diff for: src/api/services.ts

+6-6
Original file line numberDiff line numberDiff line change
@@ -6,23 +6,23 @@ import { GotClient, ServiceList, ServiceResource } from '../types';
66
const log = debug('twilio-serverless-api:services');
77

88
/**
9-
* Creates a new service given a project name
9+
* Creates a new service given a service name
1010
*
1111
* @export
12-
* @param {string} projectName the unique name for the service
12+
* @param {string} serviceName the unique name for the service
1313
* @param {GotClient} client API client
1414
* @returns {Promise<string>}
1515
*/
1616
export async function createService(
17-
projectName: string,
17+
serviceName: string,
1818
client: GotClient
1919
): Promise<string> {
2020
try {
2121
const resp = await client.post('/Services', {
2222
form: true,
2323
body: {
24-
UniqueName: projectName,
25-
FriendlyName: projectName,
24+
UniqueName: serviceName,
25+
FriendlyName: serviceName,
2626
IncludeCrendentials: true,
2727
},
2828
});
@@ -51,7 +51,7 @@ export async function listServices(
5151
}
5252

5353
/**
54-
* Tries to find the service SID associated to a project name
54+
* Tries to find the service SID associated to a service name
5555
*
5656
* @export
5757
* @param {string} uniqueName the unique name of the service

Diff for: src/client.ts

+9-11
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,7 @@ export class TwilioServerlessApiClient extends events.EventEmitter {
9999
let {
100100
types,
101101
serviceSid,
102-
projectName,
102+
serviceName: serviceName,
103103
environment: environmentSid,
104104
} = listConfig;
105105

@@ -113,9 +113,9 @@ export class TwilioServerlessApiClient extends events.EventEmitter {
113113

114114
if (
115115
typeof serviceSid === 'undefined' &&
116-
typeof projectName !== 'undefined'
116+
typeof serviceName !== 'undefined'
117117
) {
118-
serviceSid = await findServiceSid(projectName, this.client);
118+
serviceSid = await findServiceSid(serviceName, this.client);
119119
}
120120

121121
if (typeof serviceSid === 'undefined') {
@@ -278,7 +278,7 @@ export class TwilioServerlessApiClient extends events.EventEmitter {
278278
* even without a file system.
279279
*
280280
* Unless a `deployConfig. serviceSid` is specified, it will try to create one. If a service
281-
* with the name `deployConfig.projectName` already exists, it will throw
281+
* with the name `deployConfig.serviceName` already exists, it will throw
282282
* an error. You can make it use the existing service by setting `overrideExistingService` to
283283
* true.
284284
*
@@ -309,10 +309,10 @@ export class TwilioServerlessApiClient extends events.EventEmitter {
309309
message: 'Creating Service',
310310
});
311311
try {
312-
serviceSid = await createService(config.projectName, this.client);
312+
serviceSid = await createService(config.serviceName, this.client);
313313
} catch (err) {
314314
const alternativeServiceSid = await findServiceSid(
315-
config.projectName,
315+
config.serviceName,
316316
this.client
317317
);
318318
if (!alternativeServiceSid) {
@@ -322,16 +322,14 @@ export class TwilioServerlessApiClient extends events.EventEmitter {
322322
serviceSid = alternativeServiceSid;
323323
} else {
324324
const error = new Error(
325-
`Project with name "${
326-
config.projectName
327-
}" already exists with SID "${alternativeServiceSid}".`
325+
`Service with name "${config.serviceName}" already exists with SID "${alternativeServiceSid}".`
328326
);
329327
error.name = 'conflicting-servicename';
330328
Object.defineProperty(err, 'serviceSid', {
331329
value: alternativeServiceSid,
332330
});
333-
Object.defineProperty(err, 'projectName', {
334-
value: config.projectName,
331+
Object.defineProperty(err, 'serviceName', {
332+
value: config.serviceName,
335333
});
336334
throw error;
337335
}

Diff for: src/types/deploy.ts

+3-3
Original file line numberDiff line numberDiff line change
@@ -28,9 +28,9 @@ type DeployProjectConfigBase = {
2828
*/
2929
pkgJson: PackageJson;
3030
/**
31-
* Project name, used as `UniqueName` for Serverless Service.
31+
* Name, used as `UniqueName` for Serverless Service.
3232
*/
33-
projectName: string;
33+
serviceName: string;
3434
/**
3535
* Name of Functions environment to deploy to. Will be used as domain suffix and `${value}-environment` for `UniqueName`
3636
*/
@@ -40,7 +40,7 @@ type DeployProjectConfigBase = {
4040
*/
4141
force?: boolean;
4242
/**
43-
* If no `serviceSid` is specified but a service with `projectName` is found, it will deploy to that one.
43+
* If no `serviceSid` is specified but a service with `serviceName` is found, it will deploy to that one.
4444
*/
4545
overrideExistingService?: boolean;
4646
};

Diff for: src/types/list.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -35,9 +35,9 @@ export type ListConfig = ClientConfig & {
3535
*/
3636
serviceSid?: string;
3737
/**
38-
* Project namee as alternative to `serviceSid`
38+
* Service name as alternative to `serviceSid`
3939
*/
40-
projectName?: string;
40+
serviceName?: string;
4141
/**
4242
* Environment SID or domain suffix. Required to list variables, functions and assets
4343
*/

0 commit comments

Comments
 (0)