Skip to content

Commit c5aff1b

Browse files
nex3Goodwine
andauthored
Make it possible to build npm with a linked language repo (#2214)
This makes several changes: * It renames the `UPDATE_SASS_PROTOCOL` environment variable used by the Grinder `protobuf` task to `UPDATE_SASS_SASS_REPO` to make it more generic and so usable by other tasks. The previous name still works but is considered deprecated. * The `pkg-npm-*` grinder tasks now respects the `UPDATE_SASS_SASS_REPO` environment variable. This allows repos to ensure that the linked language repo's version of the TypeScript types are used when building the npm package. * `UPDATE_SASS_SASS_REPO=false` is set for all the `pkg-npm-*` tasks run by this repo, so that they will use the linked language repo's version of the TypeScript types. Co-authored-by: Carlos (Goodwine) <[email protected]>
1 parent 1137797 commit c5aff1b

File tree

4 files changed

+24
-7
lines changed

4 files changed

+24
-7
lines changed

.github/util/initialize/action.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,5 +32,5 @@ runs:
3232

3333
- name: Generate Dart from protobuf
3434
run: dart run grinder protobuf
35-
env: {UPDATE_SASS_PROTOCOL: false}
35+
env: {UPDATE_SASS_SASS_REPO: false}
3636
shell: bash

.github/workflows/release.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,7 @@ jobs:
7070
- name: Deploy
7171
run: dart run grinder pkg-npm-deploy
7272
env:
73+
UPDATE_SASS_SASS_REPO: false
7374
NPM_TOKEN: "${{ secrets.NPM_TOKEN }}"
7475

7576
deploy_bazel:

.github/workflows/test.yml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -113,6 +113,7 @@ jobs:
113113

114114
- name: Build JS
115115
run: dart run grinder pkg-npm-dev
116+
env: {UPDATE_SASS_SASS_REPO: false}
116117

117118
- name: Check out Sass specification
118119
uses: sass/clone-linked-repo@v1
@@ -203,6 +204,7 @@ jobs:
203204

204205
- name: Build JS
205206
run: dart run grinder pkg-npm-dev
207+
env: {UPDATE_SASS_SASS_REPO: false}
206208

207209
- name: Install built dependencies
208210
run: npm install
@@ -282,6 +284,7 @@ jobs:
282284
node-version: ${{ matrix.node-version }}
283285

284286
- run: dart run grinder pkg-npm-dev
287+
env: {UPDATE_SASS_SASS_REPO: false}
285288
- name: Run tests
286289
run: dart run test -t node -j 2
287290

@@ -303,6 +306,7 @@ jobs:
303306
github-token: ${{ github.token }}
304307

305308
- run: dart run grinder pkg-npm-dev
309+
env: {UPDATE_SASS_SASS_REPO: false}
306310
- name: Run tests
307311
run: dart run test -p chrome -j 2
308312
env:

tool/grind.dart

Lines changed: 18 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -213,8 +213,7 @@ String _readAndResolveMarkdown(String path) => File(path)
213213

214214
/// Returns a map from JS type declaration file names to their contnets.
215215
Map<String, String> _fetchJSTypes() {
216-
var languageRepo =
217-
cloneOrCheckout("https://github.com/sass/sass", "main", name: 'language');
216+
var languageRepo = _updateLanguageRepo();
218217

219218
var typeRoot = p.join(languageRepo, 'js-api-doc');
220219
return {
@@ -251,10 +250,7 @@ dart run protoc_plugin "\$@"
251250
run('chmod', arguments: ['a+x', 'build/protoc-gen-dart']);
252251
}
253252

254-
if (Platform.environment['UPDATE_SASS_PROTOCOL'] != 'false') {
255-
cloneOrCheckout("https://github.com/sass/sass.git", "main",
256-
name: 'language');
257-
}
253+
_updateLanguageRepo();
258254

259255
await runAsync("buf",
260256
arguments: ["generate"],
@@ -325,3 +321,19 @@ String _updateHomebrewLanguageRevision(String formula) {
325321
match.group(0)!.replaceFirst(match.group(1)!, languageRepoRevision) +
326322
formula.substring(match.end);
327323
}
324+
325+
/// Clones the main branch of `github.com/sass/sass` and returns the path to the
326+
/// clone.
327+
///
328+
/// If the `UPDATE_SASS_SASS_REPO` environment variable is `false`, this instead
329+
/// assumes the repo that already exists at `build/language/sass`.
330+
/// `UPDATE_SASS_PROTOCOL` is also checked as a deprecated alias for
331+
/// `UPDATE_SASS_SASS_REPO`.
332+
String _updateLanguageRepo() =>
333+
// UPDATE_SASS_PROTOCOL is considered deprecated, because it doesn't apply as
334+
// generically to other tasks.
335+
Platform.environment['UPDATE_SASS_SASS_REPO'] != 'false' &&
336+
Platform.environment['UPDATE_SASS_PROTOCOL'] != 'false'
337+
? cloneOrCheckout("https://github.com/sass/sass.git", "main",
338+
name: 'language')
339+
: 'build/language';

0 commit comments

Comments
 (0)