Skip to content

Commit 8bbbc92

Browse files
authored
feat(twilio-run:templates): pull function-templates from main (#182)
1 parent 5108d30 commit 8bbbc92

File tree

2 files changed

+18
-18
lines changed

2 files changed

+18
-18
lines changed

packages/twilio-run/__tests__/templating/data.test.ts

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ describe('base API configuration', () => {
1616
} = require('../../src/templating/data');
1717

1818
expect(TEMPLATES_URL).toBe(
19-
'https://raw.githubusercontent.com/twilio-labs/function-templates/master/templates.json'
19+
'https://raw.githubusercontent.com/twilio-labs/function-templates/main/templates.json'
2020
);
2121
expect(CONTENT_BASE_URL).toBe(
2222
'https://api.github.com/repos/twilio-labs/function-templates/contents'
@@ -32,7 +32,7 @@ describe('base API configuration', () => {
3232
} = require('../../src/templating/data');
3333

3434
expect(TEMPLATES_URL).toBe(
35-
'https://raw.githubusercontent.com/dkundel/function-templates/master/templates.json'
35+
'https://raw.githubusercontent.com/dkundel/function-templates/main/templates.json'
3636
);
3737
expect(CONTENT_BASE_URL).toBe(
3838
'https://api.github.com/repos/dkundel/function-templates/contents'
@@ -86,7 +86,7 @@ describe('with a mocked GitHub API', () => {
8686

8787
const basePath = '/repos/twilio-labs/function-templates/contents/blank';
8888
const templateContentScope = gitHubApi
89-
.get(`${basePath}?ref=master`)
89+
.get(`${basePath}?ref=main`)
9090
.reply(200, []);
9191
const result = await getTemplateFiles('blank');
9292

@@ -102,29 +102,29 @@ describe('with a mocked GitHub API', () => {
102102
const basePath =
103103
'/repos/twilio-labs/function-templates/contents/blank/functions';
104104
const templateContentScope = gitHubApi
105-
.get(`${basePath}?ref=master`)
105+
.get(`${basePath}?ref=main`)
106106
.reply(200, [
107107
{
108108
name: 'blank.js',
109109
path: 'blank/functions/blank.js',
110110
sha: '8ffaf92aea1c5cd224fafa30165462c9eb0214bd',
111111
size: 80,
112112
url:
113-
'https://api.github.com/repos/twilio-labs/function-templates/contents/blank/functions/blank.js?ref=master',
113+
'https://api.github.com/repos/twilio-labs/function-templates/contents/blank/functions/blank.js?ref=main',
114114
html_url:
115-
'https://github.com/twilio-labs/function-templates/blob/master/blank/functions/blank.js',
115+
'https://github.com/twilio-labs/function-templates/blob/main/blank/functions/blank.js',
116116
git_url:
117117
'https://api.github.com/repos/twilio-labs/function-templates/git/blobs/8ffaf92aea1c5cd224fafa30165462c9eb0214bd',
118118
download_url:
119-
'https://raw.githubusercontent.com/twilio-labs/function-templates/master/blank/functions/blank.js',
119+
'https://raw.githubusercontent.com/twilio-labs/function-templates/main/blank/functions/blank.js',
120120
type: 'file',
121121
_links: {
122122
self:
123-
'https://api.github.com/repos/twilio-labs/function-templates/contents/blank/functions/blank.js?ref=master',
123+
'https://api.github.com/repos/twilio-labs/function-templates/contents/blank/functions/blank.js?ref=main',
124124
git:
125125
'https://api.github.com/repos/twilio-labs/function-templates/git/blobs/8ffaf92aea1c5cd224fafa30165462c9eb0214bd',
126126
html:
127-
'https://github.com/twilio-labs/function-templates/blob/master/blank/functions/blank.js',
127+
'https://github.com/twilio-labs/function-templates/blob/main/blank/functions/blank.js',
128128
},
129129
},
130130
]);
@@ -136,27 +136,27 @@ describe('with a mocked GitHub API', () => {
136136
expect(file.name).toEqual('blank.js');
137137
expect(file.type).toEqual('functions');
138138
expect(file.content).toEqual(
139-
'https://raw.githubusercontent.com/twilio-labs/function-templates/master/blank/functions/blank.js'
139+
'https://raw.githubusercontent.com/twilio-labs/function-templates/main/blank/functions/blank.js'
140140
);
141141
});
142142

143143
test('gets a template directory with nested functions from GH and translate to template file info', async () => {
144144
const basePath =
145145
'/repos/twilio-labs/function-templates/contents/nested/functions';
146-
gitHubApi.get(`${basePath}?ref=master`).reply(200, [
146+
gitHubApi.get(`${basePath}?ref=main`).reply(200, [
147147
{
148148
name: 'blank.js',
149149
path: 'nested/functions/blank.js',
150150
sha: '8ffaf92aea1c5cd224fafa30165462c9eb0214bd',
151151
size: 80,
152152
url:
153-
'https://api.github.com/repos/twilio-labs/function-templates/contents/nested/functions/blank.js?ref=master',
153+
'https://api.github.com/repos/twilio-labs/function-templates/contents/nested/functions/blank.js?ref=main',
154154
html_url:
155-
'https://github.com/twilio-labs/function-templates/blob/master/nested/functions/blank.js',
155+
'https://github.com/twilio-labs/function-templates/blob/main/nested/functions/blank.js',
156156
git_url:
157157
'https://api.github.com/repos/twilio-labs/function-templates/git/blobs/8ffaf92aea1c5cd224fafa30165462c9eb0214bd',
158158
download_url:
159-
'https://raw.githubusercontent.com/twilio-labs/function-templates/master/nested/functions/blank.js',
159+
'https://raw.githubusercontent.com/twilio-labs/function-templates/main/nested/functions/blank.js',
160160
type: 'file',
161161
},
162162
{
@@ -203,7 +203,7 @@ describe('with a mocked GitHub API', () => {
203203
expect(file.name).toEqual('blank.js');
204204
expect(file.type).toEqual('functions');
205205
expect(file.content).toEqual(
206-
'https://raw.githubusercontent.com/twilio-labs/function-templates/master/nested/functions/blank.js'
206+
'https://raw.githubusercontent.com/twilio-labs/function-templates/main/nested/functions/blank.js'
207207
);
208208
const nestedFile = files[1];
209209
expect(nestedFile.directory).toEqual('admin');

packages/twilio-run/src/templating/data.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,16 @@
1-
import path from 'path';
21
import { stripIndent } from 'common-tags';
32
import got from 'got';
4-
import flatten from 'lodash.flatten';
53
import { OutgoingHttpHeaders } from 'http';
4+
import flatten from 'lodash.flatten';
5+
import path from 'path';
66
import { getDebugFunction } from '../utils/logger';
77
const debug = getDebugFunction('twilio-run:new:template-data');
88

99
const TEMPLATE_BASE_REPO =
1010
process.env.TWILIO_SERVERLESS_TEMPLATE_REPO ||
1111
'twilio-labs/function-templates';
1212
const TEMPLATE_BASE_BRANCH =
13-
process.env.TWILIO_SERVERLESS_TEMPLATE_BRANCH || 'master';
13+
process.env.TWILIO_SERVERLESS_TEMPLATE_BRANCH || 'main';
1414

1515
export const TEMPLATES_URL = `https://raw.githubusercontent.com/${TEMPLATE_BASE_REPO}/${TEMPLATE_BASE_BRANCH}/templates.json`;
1616
export const CONTENT_BASE_URL = `https://api.github.com/repos/${TEMPLATE_BASE_REPO}/contents`;

0 commit comments

Comments
 (0)