diff --git a/.changeset/four-fireants-try.md b/.changeset/four-fireants-try.md index 0f33ad6f4..b81ddfb7f 100644 --- a/.changeset/four-fireants-try.md +++ b/.changeset/four-fireants-try.md @@ -2,4 +2,4 @@ 'style-dictionary': patch --- -Pass outputReferencesFallback option to the relevant utilities, so the option actually works. +Pass outputReferenceFallbacks option to the relevant utilities, so the option actually works. diff --git a/.changeset/young-cameras-grin.md b/.changeset/young-cameras-grin.md new file mode 100644 index 000000000..7e1b75cd1 --- /dev/null +++ b/.changeset/young-cameras-grin.md @@ -0,0 +1,33 @@ +--- +'style-dictionary': major +--- + +BREAKING: For formats using the `fileHeader` `formatHelpers` utility, it will no longer display a timestamp in the fileHeader output by default. This is now an opt-in by setting `file.formatting.fileHeaderTimestamp` to `true`. The reason for making this opt-in now is that using Style Dictionary in the context of a CI (continuous integration) pipeline is a common use-case, and when running on pull request event, output files always show a diff in git due to the timestamp changing, which often just means that the diff is bloated by redundancy. + +New: + +```json +{ + "platforms": { + "css": { + "files": [{ + "destination": "variables.css", + "format": "css/variables", + "options": { + "formatting": { + "fileHeaderTimestamp": true + } + } + }] + } + } +} +``` + +or: + +```js +import { fileHeader } from 'style-dictionary/utils'; + +const headerContent = await fileHeader({ formatting: { fileHeaderTimestamp: true } }); +``` diff --git a/CHANGELOG.md b/CHANGELOG.md index c36e0377a..ce4e21e74 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -294,7 +294,7 @@ ### Patch Changes -- 72f020d: Pass outputReferencesFallback option to the relevant utilities, so the option actually works. +- 72f020d: Pass outputReferenceFallbacks option to the relevant utilities, so the option actually works. - d008c67: Fix a couple of spots where DTCG option wasn't properly taken into account, more tests added. ## 4.0.0-prerelease.15 diff --git a/__integration__/__snapshots__/android.test.snap.js b/__integration__/__snapshots__/android.test.snap.js index 28f26cea7..486edae29 100644 --- a/__integration__/__snapshots__/android.test.snap.js +++ b/__integration__/__snapshots__/android.test.snap.js @@ -5,8 +5,7 @@ snapshots["integration android android/resources should match snapshot"] = ` #ffffffff @@ -178,8 +177,7 @@ snapshots["integration android android/resources with references should match sn ` @color/color_core_neutral_0 @@ -351,8 +349,7 @@ snapshots["integration android android/resources with filter should match snapsh ` #ffffffff diff --git a/__integration__/__snapshots__/compose.test.snap.js b/__integration__/__snapshots__/compose.test.snap.js index 26b9a13d7..319f1ac02 100644 --- a/__integration__/__snapshots__/compose.test.snap.js +++ b/__integration__/__snapshots__/compose.test.snap.js @@ -4,8 +4,7 @@ export const snapshots = {}; snapshots["integration compose compose/object should match snapshot"] = ` -// Do not edit directly -// Generated on Sat, 01 Jan 2000 00:00:00 GMT +// Do not edit directly, this file was auto-generated. @@ -183,8 +182,7 @@ object StyleDictionary { snapshots["integration compose compose/object with references should match snapshot"] = ` -// Do not edit directly -// Generated on Sat, 01 Jan 2000 00:00:00 GMT +// Do not edit directly, this file was auto-generated. diff --git a/__integration__/__snapshots__/css.test.snap.js b/__integration__/__snapshots__/css.test.snap.js index 43f3e5cd3..b924ff480 100644 --- a/__integration__/__snapshots__/css.test.snap.js +++ b/__integration__/__snapshots__/css.test.snap.js @@ -3,8 +3,7 @@ export const snapshots = {}; snapshots["integration css css/variables should match snapshot"] = `/** - * Do not edit directly - * Generated on Sat, 01 Jan 2000 00:00:00 GMT + * Do not edit directly, this file was auto-generated. */ :root { @@ -179,8 +178,7 @@ snapshots["integration css css/variables should match snapshot"] = snapshots["integration css css/variables with references should match snapshot"] = `/** - * Do not edit directly - * Generated on Sat, 01 Jan 2000 00:00:00 GMT + * Do not edit directly, this file was auto-generated. */ :root { @@ -355,8 +353,7 @@ snapshots["integration css css/variables with references should match snapshot"] snapshots["integration css css/variables with selector should match snapshot"] = `/** - * Do not edit directly - * Generated on Sat, 01 Jan 2000 00:00:00 GMT + * Do not edit directly, this file was auto-generated. */ .test { @@ -531,8 +528,7 @@ snapshots["integration css css/variables with selector should match snapshot"] = snapshots["integration css css/variables with referenceFallbacks should match snapshot"] = `/** - * Do not edit directly - * Generated on Sat, 01 Jan 2000 00:00:00 GMT + * Do not edit directly, this file was auto-generated. */ :root { diff --git a/__integration__/__snapshots__/customFileHeader.test.snap.js b/__integration__/__snapshots__/customFileHeader.test.snap.js index 481d00748..72ed4100c 100644 --- a/__integration__/__snapshots__/customFileHeader.test.snap.js +++ b/__integration__/__snapshots__/customFileHeader.test.snap.js @@ -4,8 +4,7 @@ export const snapshots = {}; snapshots["integration valid custom file headers file options registered file header should match snapshot"] = `/** * hello - * Do not edit directly - * Generated on Sat, 01 Jan 2000 00:00:00 GMT + * Do not edit directly, this file was auto-generated. */ :root { @@ -16,8 +15,7 @@ snapshots["integration valid custom file headers file options registered file he snapshots["integration valid custom file headers file options config file header should match snapshot"] = `/** - * Do not edit directly - * Generated on Sat, 01 Jan 2000 00:00:00 GMT + * Do not edit directly, this file was auto-generated. * hello, world! */ @@ -40,8 +38,7 @@ snapshots["integration valid custom file headers file options inline file header snapshots["integration valid custom file headers platform options no file options should match snapshot"] = `/** - * Do not edit directly - * Generated on Sat, 01 Jan 2000 00:00:00 GMT + * Do not edit directly, this file was auto-generated. * hello, world! */ diff --git a/__integration__/__snapshots__/flutter.test.snap.js b/__integration__/__snapshots__/flutter.test.snap.js index d076ed077..0f33c5397 100644 --- a/__integration__/__snapshots__/flutter.test.snap.js +++ b/__integration__/__snapshots__/flutter.test.snap.js @@ -7,8 +7,7 @@ snapshots["integration flutter flutter/class.dart should match snapshot"] = // style_dictionary.dart // -// Do not edit directly -// Generated on Sat, 01 Jan 2000 00:00:00 GMT +// Do not edit directly, this file was auto-generated. @@ -188,8 +187,7 @@ snapshots["integration flutter flutter/class.dart with references should match s // style_dictionary_with_references.dart // -// Do not edit directly -// Generated on Sat, 01 Jan 2000 00:00:00 GMT +// Do not edit directly, this file was auto-generated. @@ -369,8 +367,7 @@ snapshots["integration flutter flutter/class.dart separate should match snapshot // style_dictionary_color.dart // -// Do not edit directly -// Generated on Sat, 01 Jan 2000 00:00:00 GMT +// Do not edit directly, this file was auto-generated. diff --git a/__integration__/__snapshots__/iOSObjectiveC.test.snap.js b/__integration__/__snapshots__/iOSObjectiveC.test.snap.js index 757006082..305123056 100644 --- a/__integration__/__snapshots__/iOSObjectiveC.test.snap.js +++ b/__integration__/__snapshots__/iOSObjectiveC.test.snap.js @@ -7,8 +7,7 @@ snapshots["integration ios objective-c ios/singleton.m should match snapshot"] = // singleton.m // -// Do not edit directly -// Generated on Sat, 01 Jan 2000 00:00:00 GMT +// Do not edit directly, this file was auto-generated. #import "StyleDictionary.h" @@ -1367,8 +1366,7 @@ snapshots["integration ios objective-c ios/singleton.h should match snapshot"] = // singleton.h // -// Do not edit directly -// Generated on Sat, 01 Jan 2000 00:00:00 GMT +// Do not edit directly, this file was auto-generated. #import @@ -1389,8 +1387,7 @@ snapshots["integration ios objective-c ios/color.m should match snapshot"] = // color.m // -// Do not edit directly -// Generated on Sat, 01 Jan 2000 00:00:00 GMT +// Do not edit directly, this file was auto-generated. #import "StyleDictionaryColor.h" @@ -1575,8 +1572,7 @@ snapshots["integration ios objective-c ios/color.h should match snapshot"] = // color.h // -// Do not edit directly -// Generated on Sat, 01 Jan 2000 00:00:00 GMT +// Do not edit directly, this file was auto-generated. #import @@ -1749,8 +1745,7 @@ snapshots["integration ios objective-c ios/macros.h should match snapshot"] = // macros.h // -// Do not edit directly -// Generated on Sat, 01 Jan 2000 00:00:00 GMT +// Do not edit directly, this file was auto-generated. #import @@ -1926,8 +1921,7 @@ snapshots["integration ios objective-c ios/static.h should match snapshot"] = // static.h // -// Do not edit directly -// Generated on Sat, 01 Jan 2000 00:00:00 GMT +// Do not edit directly, this file was auto-generated. #import @@ -1950,8 +1944,7 @@ snapshots["integration ios objective-c ios/static.m should match snapshot"] = // static.m // -// Do not edit directly -// Generated on Sat, 01 Jan 2000 00:00:00 GMT +// Do not edit directly, this file was auto-generated. #import "StyleDictionaryStatic.h" diff --git a/__integration__/__snapshots__/objectValues.test.snap.js b/__integration__/__snapshots__/objectValues.test.snap.js index 61c01eb73..6572523ce 100644 --- a/__integration__/__snapshots__/objectValues.test.snap.js +++ b/__integration__/__snapshots__/objectValues.test.snap.js @@ -123,8 +123,7 @@ $border-primary: $size-border solid $color-red; snapshots["integration object values css/variables shadow should match snapshot with references"] = `/** - * Do not edit directly - * Generated on Sat, 01 Jan 2000 00:00:00 GMT + * Do not edit directly, this file was auto-generated. */ :root { @@ -136,8 +135,7 @@ snapshots["integration object values css/variables shadow should match snapshot snapshots["integration object values css/variables hsl syntax should match snapshot"] = `/** - * Do not edit directly - * Generated on Sat, 01 Jan 2000 00:00:00 GMT + * Do not edit directly, this file was auto-generated. */ :root { @@ -149,8 +147,7 @@ snapshots["integration object values css/variables hsl syntax should match snaps snapshots["integration object values css/variables hsl syntax with references should match snapshot"] = `/** - * Do not edit directly - * Generated on Sat, 01 Jan 2000 00:00:00 GMT + * Do not edit directly, this file was auto-generated. */ :root { @@ -162,8 +159,7 @@ snapshots["integration object values css/variables hsl syntax with references sh snapshots["integration object values css/variables hex syntax should match snapshot"] = `/** - * Do not edit directly - * Generated on Sat, 01 Jan 2000 00:00:00 GMT + * Do not edit directly, this file was auto-generated. */ :root { @@ -175,8 +171,7 @@ snapshots["integration object values css/variables hex syntax should match snaps snapshots["integration object values css/variables hex syntax with references should match snapshot"] = `/** - * Do not edit directly - * Generated on Sat, 01 Jan 2000 00:00:00 GMT + * Do not edit directly, this file was auto-generated. */ :root { @@ -188,8 +183,7 @@ snapshots["integration object values css/variables hex syntax with references sh snapshots["integration object values css/variables border should match snapshot"] = `/** - * Do not edit directly - * Generated on Sat, 01 Jan 2000 00:00:00 GMT + * Do not edit directly, this file was auto-generated. */ :root { @@ -200,8 +194,7 @@ snapshots["integration object values css/variables border should match snapshot" snapshots["integration object values css/variables border with references should match snapshot"] = `/** - * Do not edit directly - * Generated on Sat, 01 Jan 2000 00:00:00 GMT + * Do not edit directly, this file was auto-generated. */ :root { @@ -212,8 +205,7 @@ snapshots["integration object values css/variables border with references should snapshots["integration object values css/variables shadow should match snapshot"] = `/** - * Do not edit directly - * Generated on Sat, 01 Jan 2000 00:00:00 GMT + * Do not edit directly, this file was auto-generated. */ :root { @@ -225,8 +217,7 @@ snapshots["integration object values css/variables shadow should match snapshot" snapshots["integration object values scss/variables should match snapshot"] = ` -// Do not edit directly -// Generated on Sat, 01 Jan 2000 00:00:00 GMT +// Do not edit directly, this file was auto-generated. $border-primary: 0.125rem solid #ff0000; `; @@ -234,8 +225,7 @@ $border-primary: 0.125rem solid #ff0000; snapshots["integration object values scss/variables with references should match snapshot"] = ` -// Do not edit directly -// Generated on Sat, 01 Jan 2000 00:00:00 GMT +// Do not edit directly, this file was auto-generated. $border-primary: $size-border solid $color-red; `; diff --git a/__integration__/__snapshots__/outputReferences.test.snap.js b/__integration__/__snapshots__/outputReferences.test.snap.js index 0ae951d5f..61c38b74f 100644 --- a/__integration__/__snapshots__/outputReferences.test.snap.js +++ b/__integration__/__snapshots__/outputReferences.test.snap.js @@ -30,8 +30,7 @@ css snapshots["integration output references should allow using outputReferencesTransformed to not output refs when value has been transitively transformed"] = `/** - * Do not edit directly - * Generated on Sat, 01 Jan 2000 00:00:00 GMT + * Do not edit directly, this file was auto-generated. */ :root { diff --git a/__integration__/__snapshots__/scss.test.snap.js b/__integration__/__snapshots__/scss.test.snap.js index 997fea3fd..f6f6234c5 100644 --- a/__integration__/__snapshots__/scss.test.snap.js +++ b/__integration__/__snapshots__/scss.test.snap.js @@ -3,8 +3,7 @@ export const snapshots = {}; snapshots["integration scss scss/variables should match snapshot"] = ` -// Do not edit directly -// Generated on Sat, 01 Jan 2000 00:00:00 GMT +// Do not edit directly, this file was auto-generated. $color-background-primary: #ffffff !default; $color-background-secondary: #f3f4f4; @@ -173,8 +172,7 @@ $size-padding-xl: 1rem; snapshots["integration scss scss/variables with themeable should match snapshot"] = ` -// Do not edit directly -// Generated on Sat, 01 Jan 2000 00:00:00 GMT +// Do not edit directly, this file was auto-generated. $color-background-primary: #ffffff !default; $color-background-secondary: #f3f4f4 !default; @@ -343,8 +341,7 @@ $size-padding-xl: 1rem !default; snapshots["integration scss scss/variables with outputReferences should match snapshot"] = ` -// Do not edit directly -// Generated on Sat, 01 Jan 2000 00:00:00 GMT +// Do not edit directly, this file was auto-generated. $size-padding-xl: 1rem; $size-padding-large: 1rem; @@ -513,8 +510,7 @@ $color-background-disabled: $color-background-tertiary; snapshots["integration scss scss/variables with filter and output references should match snapshot"] = ` -// Do not edit directly -// Generated on Sat, 01 Jan 2000 00:00:00 GMT +// Do not edit directly, this file was auto-generated. $color-background-info: $color-core-blue-0; $color-background-success: $color-core-green-0; @@ -530,8 +526,7 @@ $color-background-disabled: $color-background-tertiary; snapshots["integration scss scss/map-flat should match snapshot"] = ` /** - * Do not edit directly - * Generated on Sat, 01 Jan 2000 00:00:00 GMT + * Do not edit directly, this file was auto-generated. */ $design-system-tokens: ( @@ -703,8 +698,7 @@ $design-system-tokens: ( snapshots["integration scss scss/map-deep should match snapshot"] = ` /** - * Do not edit directly - * Generated on Sat, 01 Jan 2000 00:00:00 GMT + * Do not edit directly, this file was auto-generated. */ $color-background-primary: #ffffff !default; @@ -1092,8 +1086,7 @@ $design-system-tokens: ( snapshots["integration scss scss/map-deep with outputReferences should match snapshot"] = ` /** - * Do not edit directly - * Generated on Sat, 01 Jan 2000 00:00:00 GMT + * Do not edit directly, this file was auto-generated. */ $size-padding-xl: 1rem !default; @@ -1481,8 +1474,7 @@ $design-system-tokens: ( snapshots["integration scss scss/map-deep without themeable should match snapshot"] = ` /** - * Do not edit directly - * Generated on Sat, 01 Jan 2000 00:00:00 GMT + * Do not edit directly, this file was auto-generated. */ $color-background-primary: #ffffff !default; diff --git a/__integration__/__snapshots__/showFileHeader.test.snap.js b/__integration__/__snapshots__/showFileHeader.test.snap.js index 3307b14cc..a5b0dfa81 100644 --- a/__integration__/__snapshots__/showFileHeader.test.snap.js +++ b/__integration__/__snapshots__/showFileHeader.test.snap.js @@ -3,8 +3,7 @@ export const snapshots = {}; snapshots["integration showFileHeader without platform options should show file header if no file options set"] = `/** - * Do not edit directly - * Generated on Sat, 01 Jan 2000 00:00:00 GMT + * Do not edit directly, this file was auto-generated. */ :root { @@ -38,8 +37,7 @@ snapshots["integration showFileHeader with platform options set to false should snapshots["integration showFileHeader with platform options set to false should show file header if file options set to true"] = `/** - * Do not edit directly - * Generated on Sat, 01 Jan 2000 00:00:00 GMT + * Do not edit directly, this file was auto-generated. */ :root { diff --git a/__integration__/__snapshots__/swift.test.snap.js b/__integration__/__snapshots__/swift.test.snap.js index 6de5580e6..f54195afb 100644 --- a/__integration__/__snapshots__/swift.test.snap.js +++ b/__integration__/__snapshots__/swift.test.snap.js @@ -7,8 +7,7 @@ snapshots["integration swift ios-swift/class.swift should match snapshot"] = // style_dictionary.swift // -// Do not edit directly -// Generated on Sat, 01 Jan 2000 00:00:00 GMT +// Do not edit directly, this file was auto-generated. import UIKit @@ -185,8 +184,7 @@ snapshots["integration swift ios-swift/class.swift with references should match // style_dictionary_with_references.swift // -// Do not edit directly -// Generated on Sat, 01 Jan 2000 00:00:00 GMT +// Do not edit directly, this file was auto-generated. import UIKit diff --git a/__integration__/__snapshots__/w3c-forward-compat.test.snap.js b/__integration__/__snapshots__/w3c-forward-compat.test.snap.js index ae017dd23..073b827b7 100644 --- a/__integration__/__snapshots__/w3c-forward-compat.test.snap.js +++ b/__integration__/__snapshots__/w3c-forward-compat.test.snap.js @@ -3,8 +3,7 @@ export const snapshots = {}; snapshots["integration DTCG draft spec forward compatibility should match snapshot"] = `/** - * Do not edit directly - * Generated on Sat, 01 Jan 2000 00:00:00 GMT + * Do not edit directly, this file was auto-generated. */ :root { diff --git a/__tests__/common/formatHelpers/fileHeader.test.js b/__tests__/common/formatHelpers/fileHeader.test.js index d656e5a04..af7f01e34 100644 --- a/__tests__/common/formatHelpers/fileHeader.test.js +++ b/__tests__/common/formatHelpers/fileHeader.test.js @@ -14,7 +14,7 @@ import { expect } from 'chai'; import { fixDate } from '../../__helpers.js'; import fileHeader from '../../../lib/common/formatHelpers/fileHeader.js'; -const defaultLine1 = `Do not edit directly`; +const defaultLine1 = `Do not edit directly, this file was auto-generated.`; const defaultLine2 = `Generated on Sat, 01 Jan 2000 00:00:00 GMT`; describe('common', () => { @@ -30,6 +30,17 @@ describe('common', () => { expect(comment).to.equal( `/** * ${defaultLine1} + */ + +`, + ); + }); + + it(`should allow adding timestamp to the fileheader`, async () => { + const comment = await fileHeader({ formatting: { fileHeaderTimestamp: true } }); + expect(comment).to.equal( + `/** + * ${defaultLine1} * ${defaultLine2} */ @@ -42,7 +53,6 @@ describe('common', () => { expect(comment).to.equal( ` // ${defaultLine1} -// ${defaultLine2} `, ); @@ -53,7 +63,6 @@ describe('common', () => { expect(comment).to.equal( ``, ); }); @@ -102,7 +111,6 @@ describe('common', () => { expect(comment).to.equal( `/** * ${defaultLine1} - * ${defaultLine2} * Never gonna give you up * Never gonna let you down */ @@ -122,7 +130,6 @@ describe('common', () => { expect(comment).to.equal( `{# ${defaultLine1} - ${defaultLine2} #}`, ); }); diff --git a/__tests__/formats/__snapshots__/all.test.snap.js b/__tests__/formats/__snapshots__/all.test.snap.js index e3154a6b3..2eed5c385 100644 --- a/__tests__/formats/__snapshots__/all.test.snap.js +++ b/__tests__/formats/__snapshots__/all.test.snap.js @@ -3,8 +3,7 @@ export const snapshots = {}; snapshots["formats all should match css/variables snapshot"] = `/** - * Do not edit directly - * Generated on Sat, 01 Jan 2000 00:00:00 GMT + * Do not edit directly, this file was auto-generated. */ :root { @@ -16,8 +15,7 @@ snapshots["formats all should match css/variables snapshot"] = snapshots["formats all should match scss/map-flat snapshot"] = ` /** - * Do not edit directly - * Generated on Sat, 01 Jan 2000 00:00:00 GMT + * Do not edit directly, this file was auto-generated. */ $tokens: ( @@ -29,8 +27,7 @@ $tokens: ( snapshots["formats all should match scss/map-deep snapshot"] = ` /** - * Do not edit directly - * Generated on Sat, 01 Jan 2000 00:00:00 GMT + * Do not edit directly, this file was auto-generated. */ $color_red: #FF0000 !default; // comment @@ -45,8 +42,7 @@ $tokens: ( snapshots["formats all should match scss/variables snapshot"] = ` -// Do not edit directly -// Generated on Sat, 01 Jan 2000 00:00:00 GMT +// Do not edit directly, this file was auto-generated. $color_red: #FF0000; // comment `; @@ -54,16 +50,14 @@ $color_red: #FF0000; // comment snapshots["formats all should match scss/icons snapshot"] = ` -// Do not edit directly -// Generated on Sat, 01 Jan 2000 00:00:00 GMT +// Do not edit directly, this file was auto-generated. `; /* end snapshot formats all should match scss/icons snapshot */ snapshots["formats all should match less/variables snapshot"] = ` -// Do not edit directly -// Generated on Sat, 01 Jan 2000 00:00:00 GMT +// Do not edit directly, this file was auto-generated. @color_red: #FF0000; // comment `; @@ -71,16 +65,14 @@ snapshots["formats all should match less/variables snapshot"] = snapshots["formats all should match less/icons snapshot"] = ` -// Do not edit directly -// Generated on Sat, 01 Jan 2000 00:00:00 GMT +// Do not edit directly, this file was auto-generated. `; /* end snapshot formats all should match less/icons snapshot */ snapshots["formats all should match stylus/variables snapshot"] = ` -// Do not edit directly -// Generated on Sat, 01 Jan 2000 00:00:00 GMT +// Do not edit directly, this file was auto-generated. $color_red= #FF0000; // comment `; @@ -88,8 +80,7 @@ $color_red= #FF0000; // comment snapshots["formats all should match javascript/module snapshot"] = `/** - * Do not edit directly - * Generated on Sat, 01 Jan 2000 00:00:00 GMT + * Do not edit directly, this file was auto-generated. */ module.exports = { @@ -114,8 +105,7 @@ module.exports = { snapshots["formats all should match javascript/module-flat snapshot"] = `/** - * Do not edit directly - * Generated on Sat, 01 Jan 2000 00:00:00 GMT + * Do not edit directly, this file was auto-generated. */ module.exports = { @@ -126,8 +116,7 @@ module.exports = { snapshots["formats all should match javascript/object snapshot"] = `/** - * Do not edit directly - * Generated on Sat, 01 Jan 2000 00:00:00 GMT + * Do not edit directly, this file was auto-generated. */ var _styleDictionary = { @@ -152,8 +141,7 @@ var _styleDictionary = { snapshots["formats all should match javascript/umd snapshot"] = `/** - * Do not edit directly - * Generated on Sat, 01 Jan 2000 00:00:00 GMT + * Do not edit directly, this file was auto-generated. */ (function(root, factory) { @@ -190,8 +178,7 @@ snapshots["formats all should match javascript/umd snapshot"] = snapshots["formats all should match javascript/es6 snapshot"] = `/** - * Do not edit directly - * Generated on Sat, 01 Jan 2000 00:00:00 GMT + * Do not edit directly, this file was auto-generated. */ export const color_red = "#FF0000"; // comment @@ -200,8 +187,7 @@ export const color_red = "#FF0000"; // comment snapshots["formats all should match typescript/es6-declarations snapshot"] = `/** - * Do not edit directly - * Generated on Sat, 01 Jan 2000 00:00:00 GMT + * Do not edit directly, this file was auto-generated. */ /** comment */ @@ -211,8 +197,7 @@ export const color_red : string; snapshots["formats all should match typescript/module-declarations snapshot"] = `/** - * Do not edit directly - * Generated on Sat, 01 Jan 2000 00:00:00 GMT + * Do not edit directly, this file was auto-generated. */ export default tokens; @@ -239,8 +224,7 @@ snapshots["formats all should match android/resources snapshot"] = ` #FF0000 @@ -251,8 +235,7 @@ snapshots["formats all should match android/colors snapshot"] = ` #FF0000 @@ -263,8 +246,7 @@ snapshots["formats all should match android/dimens snapshot"] = ` @@ -275,8 +257,7 @@ snapshots["formats all should match android/fontDimens snapshot"] = ` @@ -287,8 +268,7 @@ snapshots["formats all should match android/integers snapshot"] = ` @@ -299,8 +279,7 @@ snapshots["formats all should match android/strings snapshot"] = ` @@ -310,8 +289,7 @@ snapshots["formats all should match android/strings snapshot"] = snapshots["formats all should match compose/object snapshot"] = ` -// Do not edit directly -// Generated on Sat, 01 Jan 2000 00:00:00 GMT +// Do not edit directly, this file was auto-generated. @@ -332,8 +310,7 @@ snapshots["formats all should match ios/macros snapshot"] = // __output/ // -// Do not edit directly -// Generated on Sat, 01 Jan 2000 00:00:00 GMT +// Do not edit directly, this file was auto-generated. #import @@ -348,8 +325,7 @@ snapshots["formats all should match ios/plist snapshot"] = @@ -375,8 +351,7 @@ snapshots["formats all should match ios/singleton.m snapshot"] = // __output/ // -// Do not edit directly -// Generated on Sat, 01 Jan 2000 00:00:00 GMT +// Do not edit directly, this file was auto-generated. #import ".h" @@ -420,8 +395,7 @@ snapshots["formats all should match ios/singleton.h snapshot"] = // __output/ // -// Do not edit directly -// Generated on Sat, 01 Jan 2000 00:00:00 GMT +// Do not edit directly, this file was auto-generated. #import @@ -441,8 +415,7 @@ snapshots["formats all should match ios/static.h snapshot"] = // __output/ // -// Do not edit directly -// Generated on Sat, 01 Jan 2000 00:00:00 GMT +// Do not edit directly, this file was auto-generated. #import @@ -457,8 +430,7 @@ snapshots["formats all should match ios/static.m snapshot"] = // __output/ // -// Do not edit directly -// Generated on Sat, 01 Jan 2000 00:00:00 GMT +// Do not edit directly, this file was auto-generated. #import ".h" @@ -473,8 +445,7 @@ snapshots["formats all should match ios/colors.h snapshot"] = // __output/ // -// Do not edit directly -// Generated on Sat, 01 Jan 2000 00:00:00 GMT +// Do not edit directly, this file was auto-generated. #import @@ -495,8 +466,7 @@ snapshots["formats all should match ios/colors.m snapshot"] = // __output/ // -// Do not edit directly -// Generated on Sat, 01 Jan 2000 00:00:00 GMT +// Do not edit directly, this file was auto-generated. #import ".h" @@ -529,8 +499,7 @@ snapshots["formats all should match ios/strings.h snapshot"] = // __output/ // -// Do not edit directly -// Generated on Sat, 01 Jan 2000 00:00:00 GMT +// Do not edit directly, this file was auto-generated. #import @@ -549,8 +518,7 @@ snapshots["formats all should match ios/strings.m snapshot"] = // __output/ // -// Do not edit directly -// Generated on Sat, 01 Jan 2000 00:00:00 GMT +// Do not edit directly, this file was auto-generated. #import ".h" @@ -587,8 +555,7 @@ snapshots["formats all should match ios-swift/class.swift snapshot"] = // __output/ // -// Do not edit directly -// Generated on Sat, 01 Jan 2000 00:00:00 GMT +// Do not edit directly, this file was auto-generated. import UIKit @@ -604,8 +571,7 @@ snapshots["formats all should match ios-swift/enum.swift snapshot"] = // __output/ // -// Do not edit directly -// Generated on Sat, 01 Jan 2000 00:00:00 GMT +// Do not edit directly, this file was auto-generated. import UIKit @@ -621,8 +587,7 @@ snapshots["formats all should match ios-swift/any.swift snapshot"] = // __output/ // -// Do not edit directly -// Generated on Sat, 01 Jan 2000 00:00:00 GMT +// Do not edit directly, this file was auto-generated. import UIKit @@ -710,8 +675,7 @@ snapshots["formats all should match flutter/class.dart snapshot"] = // __output/ // -// Do not edit directly -// Generated on Sat, 01 Jan 2000 00:00:00 GMT +// Do not edit directly, this file was auto-generated. @@ -822,3 +786,730 @@ snapshots["formats all should match registerCustomFormatWithNewArgs snapshot"] = }`; /* end snapshot formats all should match registerCustomFormatWithNewArgs snapshot */ +snapshots["formats all should match css/variables snapshot with fileHeaderTimestamp set"] = +`/** + * Do not edit directly, this file was auto-generated. + * Generated on Sat, 01 Jan 2000 00:00:00 GMT + */ + +:root { + --color_red: #FF0000; /* comment */ +} +`; +/* end snapshot formats all should match css/variables snapshot with fileHeaderTimestamp set */ + +snapshots["formats all should match scss/map-flat snapshot with fileHeaderTimestamp set"] = +` +/** + * Do not edit directly, this file was auto-generated. + * Generated on Sat, 01 Jan 2000 00:00:00 GMT + */ + +$tokens: ( + // comment + 'color_red': #FF0000 +);`; +/* end snapshot formats all should match scss/map-flat snapshot with fileHeaderTimestamp set */ + +snapshots["formats all should match scss/map-deep snapshot with fileHeaderTimestamp set"] = +` +/** + * Do not edit directly, this file was auto-generated. + * Generated on Sat, 01 Jan 2000 00:00:00 GMT + */ + +$color_red: #FF0000 !default; // comment + +$tokens: ( + 'color': ( + 'red': $color_red + ) +); +`; +/* end snapshot formats all should match scss/map-deep snapshot with fileHeaderTimestamp set */ + +snapshots["formats all should match scss/variables snapshot with fileHeaderTimestamp set"] = +` +// Do not edit directly, this file was auto-generated. +// Generated on Sat, 01 Jan 2000 00:00:00 GMT + +$color_red: #FF0000; // comment +`; +/* end snapshot formats all should match scss/variables snapshot with fileHeaderTimestamp set */ + +snapshots["formats all should match scss/icons snapshot with fileHeaderTimestamp set"] = +` +// Do not edit directly, this file was auto-generated. +// Generated on Sat, 01 Jan 2000 00:00:00 GMT + +`; +/* end snapshot formats all should match scss/icons snapshot with fileHeaderTimestamp set */ + +snapshots["formats all should match less/variables snapshot with fileHeaderTimestamp set"] = +` +// Do not edit directly, this file was auto-generated. +// Generated on Sat, 01 Jan 2000 00:00:00 GMT + +@color_red: #FF0000; // comment +`; +/* end snapshot formats all should match less/variables snapshot with fileHeaderTimestamp set */ + +snapshots["formats all should match less/icons snapshot with fileHeaderTimestamp set"] = +` +// Do not edit directly, this file was auto-generated. +// Generated on Sat, 01 Jan 2000 00:00:00 GMT + +`; +/* end snapshot formats all should match less/icons snapshot with fileHeaderTimestamp set */ + +snapshots["formats all should match stylus/variables snapshot with fileHeaderTimestamp set"] = +` +// Do not edit directly, this file was auto-generated. +// Generated on Sat, 01 Jan 2000 00:00:00 GMT + +$color_red= #FF0000; // comment +`; +/* end snapshot formats all should match stylus/variables snapshot with fileHeaderTimestamp set */ + +snapshots["formats all should match javascript/module snapshot with fileHeaderTimestamp set"] = +`/** + * Do not edit directly, this file was auto-generated. + * Generated on Sat, 01 Jan 2000 00:00:00 GMT + */ + +module.exports = { + "color": { + "red": { + "value": "#FF0000", + "type": "color", + "original": { + "value": "#FF0000" + }, + "name": "color_red", + "comment": "comment", + "path": [ + "color", + "red" + ] + } + } +}; +`; +/* end snapshot formats all should match javascript/module snapshot with fileHeaderTimestamp set */ + +snapshots["formats all should match javascript/module-flat snapshot with fileHeaderTimestamp set"] = +`/** + * Do not edit directly, this file was auto-generated. + * Generated on Sat, 01 Jan 2000 00:00:00 GMT + */ + +module.exports = { + "color_red": "#FF0000" +}; +`; +/* end snapshot formats all should match javascript/module-flat snapshot with fileHeaderTimestamp set */ + +snapshots["formats all should match javascript/object snapshot with fileHeaderTimestamp set"] = +`/** + * Do not edit directly, this file was auto-generated. + * Generated on Sat, 01 Jan 2000 00:00:00 GMT + */ + +var _styleDictionary = { + "color": { + "red": { + "value": "#FF0000", + "type": "color", + "original": { + "value": "#FF0000" + }, + "name": "color_red", + "comment": "comment", + "path": [ + "color", + "red" + ] + } + } +}; +`; +/* end snapshot formats all should match javascript/object snapshot with fileHeaderTimestamp set */ + +snapshots["formats all should match javascript/umd snapshot with fileHeaderTimestamp set"] = +`/** + * Do not edit directly, this file was auto-generated. + * Generated on Sat, 01 Jan 2000 00:00:00 GMT + */ + +(function(root, factory) { + if (typeof module === "object" && module.exports) { + module.exports = factory(); + } else if (typeof exports === "object") { + exports["_styleDictionary"] = factory(); + } else if (typeof define === "function" && define.amd) { + define([], factory); + } else { + root["_styleDictionary"] = factory(); + } +}(this, function() { + return { + "color": { + "red": { + "value": "#FF0000", + "type": "color", + "original": { + "value": "#FF0000" + }, + "name": "color_red", + "comment": "comment", + "path": [ + "color", + "red" + ] + } + } +}; +})) +`; +/* end snapshot formats all should match javascript/umd snapshot with fileHeaderTimestamp set */ + +snapshots["formats all should match javascript/es6 snapshot with fileHeaderTimestamp set"] = +`/** + * Do not edit directly, this file was auto-generated. + * Generated on Sat, 01 Jan 2000 00:00:00 GMT + */ + +export const color_red = "#FF0000"; // comment +`; +/* end snapshot formats all should match javascript/es6 snapshot with fileHeaderTimestamp set */ + +snapshots["formats all should match typescript/es6-declarations snapshot with fileHeaderTimestamp set"] = +`/** + * Do not edit directly, this file was auto-generated. + * Generated on Sat, 01 Jan 2000 00:00:00 GMT + */ + +/** comment */ +export const color_red : string; +`; +/* end snapshot formats all should match typescript/es6-declarations snapshot with fileHeaderTimestamp set */ + +snapshots["formats all should match typescript/module-declarations snapshot with fileHeaderTimestamp set"] = +`/** + * Do not edit directly, this file was auto-generated. + * Generated on Sat, 01 Jan 2000 00:00:00 GMT + */ + +export default tokens; + +declare interface DesignToken { + value?: any; + type?: string; + comment?: string; + name?: string; + themeable?: boolean; + attributes?: Record; + [key: string]: any; +} + +declare const tokens: { + "color": { + "red": DesignToken + } +} +`; +/* end snapshot formats all should match typescript/module-declarations snapshot with fileHeaderTimestamp set */ + +snapshots["formats all should match android/resources snapshot with fileHeaderTimestamp set"] = +` + + + + #FF0000 +`; +/* end snapshot formats all should match android/resources snapshot with fileHeaderTimestamp set */ + +snapshots["formats all should match android/colors snapshot with fileHeaderTimestamp set"] = +` + + + + #FF0000 +`; +/* end snapshot formats all should match android/colors snapshot with fileHeaderTimestamp set */ + +snapshots["formats all should match android/dimens snapshot with fileHeaderTimestamp set"] = +` + + + + +`; +/* end snapshot formats all should match android/dimens snapshot with fileHeaderTimestamp set */ + +snapshots["formats all should match android/fontDimens snapshot with fileHeaderTimestamp set"] = +` + + + + +`; +/* end snapshot formats all should match android/fontDimens snapshot with fileHeaderTimestamp set */ + +snapshots["formats all should match android/integers snapshot with fileHeaderTimestamp set"] = +` + + + + +`; +/* end snapshot formats all should match android/integers snapshot with fileHeaderTimestamp set */ + +snapshots["formats all should match android/strings snapshot with fileHeaderTimestamp set"] = +` + + + + +`; +/* end snapshot formats all should match android/strings snapshot with fileHeaderTimestamp set */ + +snapshots["formats all should match compose/object snapshot with fileHeaderTimestamp set"] = +` + +// Do not edit directly, this file was auto-generated. +// Generated on Sat, 01 Jan 2000 00:00:00 GMT + + + +package ; + +import androidx.compose.ui.graphics.Color +import androidx.compose.ui.unit.* + +object { + /** comment */ + val color_red = #FF0000 +}`; +/* end snapshot formats all should match compose/object snapshot with fileHeaderTimestamp set */ + +snapshots["formats all should match ios/macros snapshot with fileHeaderTimestamp set"] = +` +// +// __output/ +// + +// Do not edit directly, this file was auto-generated. +// Generated on Sat, 01 Jan 2000 00:00:00 GMT + + +#import +#import + +#define color_red #FF0000 +`; +/* end snapshot formats all should match ios/macros snapshot with fileHeaderTimestamp set */ + +snapshots["formats all should match ios/plist snapshot with fileHeaderTimestamp set"] = +` + + + + + + color_red + + r + NaN + g + NaN + b + NaN + a + 1 + + + +`; +/* end snapshot formats all should match ios/plist snapshot with fileHeaderTimestamp set */ + +snapshots["formats all should match ios/singleton.m snapshot with fileHeaderTimestamp set"] = +` +// +// __output/ +// + +// Do not edit directly, this file was auto-generated. +// Generated on Sat, 01 Jan 2000 00:00:00 GMT + + +#import ".h" + +@implementation + ++ (NSDictionary *)getProperty:(NSString *)keyPath { + return [[self properties] valueForKeyPath:keyPath]; +} + ++ (nonnull)getValue:(NSString *)keyPath { + return [[self properties] valueForKeyPath:[NSString stringWithFormat:@"%@.value", keyPath]]; +} + ++ (NSDictionary *)properties { + static NSDictionary * dictionary; + static dispatch_once_t onceToken; + + dispatch_once(&onceToken, ^{ + dictionary = @{ + @"color": @{ + @"red": @{ + @"value": #FF0000, + @"name": @"color_red" + } + } + }; + }); + + return dictionary; +} + +@end + +`; +/* end snapshot formats all should match ios/singleton.m snapshot with fileHeaderTimestamp set */ + +snapshots["formats all should match ios/singleton.h snapshot with fileHeaderTimestamp set"] = +` +// +// __output/ +// + +// Do not edit directly, this file was auto-generated. +// Generated on Sat, 01 Jan 2000 00:00:00 GMT + + +#import +#import + +@interface : NSObject + ++ (NSDictionary *)properties; ++ (NSDictionary *)getProperty:(NSString *)keyPath; ++ (nonnull)getValue:(NSString *)keyPath; + +@end`; +/* end snapshot formats all should match ios/singleton.h snapshot with fileHeaderTimestamp set */ + +snapshots["formats all should match ios/static.h snapshot with fileHeaderTimestamp set"] = +` +// __output/ +// + +// Do not edit directly, this file was auto-generated. +// Generated on Sat, 01 Jan 2000 00:00:00 GMT + + +#import + + +extern const color_red;`; +/* end snapshot formats all should match ios/static.h snapshot with fileHeaderTimestamp set */ + +snapshots["formats all should match ios/static.m snapshot with fileHeaderTimestamp set"] = +` +// +// __output/ +// + +// Do not edit directly, this file was auto-generated. +// Generated on Sat, 01 Jan 2000 00:00:00 GMT + + +#import ".h" + + +const color_red = #FF0000;`; +/* end snapshot formats all should match ios/static.m snapshot with fileHeaderTimestamp set */ + +snapshots["formats all should match ios/colors.h snapshot with fileHeaderTimestamp set"] = +` +// +// __output/ +// + +// Do not edit directly, this file was auto-generated. +// Generated on Sat, 01 Jan 2000 00:00:00 GMT + + +#import + +typedef NS_ENUM(NSInteger, ) { +color_red +}; + +@interface : NSObject ++ (NSArray *)values; ++ (UIColor *)color:()color; +@end`; +/* end snapshot formats all should match ios/colors.h snapshot with fileHeaderTimestamp set */ + +snapshots["formats all should match ios/colors.m snapshot with fileHeaderTimestamp set"] = +` +// +// __output/ +// + +// Do not edit directly, this file was auto-generated. +// Generated on Sat, 01 Jan 2000 00:00:00 GMT + + +#import ".h" + +@implementation + ++ (UIColor *)color:()colorEnum{ + return [[self values] objectAtIndex:colorEnum]; +} + ++ (NSArray *)values { + static NSArray* colorArray; + static dispatch_once_t onceToken; + + dispatch_once(&onceToken, ^{ + colorArray = @[ +#FF0000 + ]; + }); + + return colorArray; +} + +@end`; +/* end snapshot formats all should match ios/colors.m snapshot with fileHeaderTimestamp set */ + +snapshots["formats all should match ios/strings.h snapshot with fileHeaderTimestamp set"] = +` +// +// __output/ +// + +// Do not edit directly, this file was auto-generated. +// Generated on Sat, 01 Jan 2000 00:00:00 GMT + + +#import + + +extern NSString * const color_red; + +@interface : NSObject ++ (NSArray *)values; +@end`; +/* end snapshot formats all should match ios/strings.h snapshot with fileHeaderTimestamp set */ + +snapshots["formats all should match ios/strings.m snapshot with fileHeaderTimestamp set"] = +` +// +// __output/ +// + +// Do not edit directly, this file was auto-generated. +// Generated on Sat, 01 Jan 2000 00:00:00 GMT + + +#import ".h" + + +NSString * const color_red = #FF0000; + +@implementation + ++ (NSArray *)values { + static NSArray* array; + static dispatch_once_t onceToken; + + dispatch_once(&onceToken, ^{ + array = @[ + @{ + @"value": #FF0000, + @"name": @"color_red" + } + ]; + }); + + return array; +} + +@end + +`; +/* end snapshot formats all should match ios/strings.m snapshot with fileHeaderTimestamp set */ + +snapshots["formats all should match ios-swift/class.swift snapshot with fileHeaderTimestamp set"] = +` +// +// __output/ +// + +// Do not edit directly, this file was auto-generated. +// Generated on Sat, 01 Jan 2000 00:00:00 GMT + + +import UIKit + +public class { + public static let color_red = #FF0000 /* comment */ +}`; +/* end snapshot formats all should match ios-swift/class.swift snapshot with fileHeaderTimestamp set */ + +snapshots["formats all should match ios-swift/enum.swift snapshot with fileHeaderTimestamp set"] = +` +// +// __output/ +// + +// Do not edit directly, this file was auto-generated. +// Generated on Sat, 01 Jan 2000 00:00:00 GMT + + +import UIKit + +public enum { + public static let color_red = #FF0000 /* comment */ +}`; +/* end snapshot formats all should match ios-swift/enum.swift snapshot with fileHeaderTimestamp set */ + +snapshots["formats all should match ios-swift/any.swift snapshot with fileHeaderTimestamp set"] = +` +// +// __output/ +// + +// Do not edit directly, this file was auto-generated. +// Generated on Sat, 01 Jan 2000 00:00:00 GMT + + +import UIKit + +public class { + public static let color_red = #FF0000 /* comment */ +}`; +/* end snapshot formats all should match ios-swift/any.swift snapshot with fileHeaderTimestamp set */ + +snapshots["formats all should match css/fonts.css snapshot with fileHeaderTimestamp set"] = +``; +/* end snapshot formats all should match css/fonts.css snapshot with fileHeaderTimestamp set */ + +snapshots["formats all should match json snapshot with fileHeaderTimestamp set"] = +`{ + "color": { + "red": { + "value": "#FF0000", + "type": "color", + "original": { + "value": "#FF0000" + }, + "name": "color_red", + "comment": "comment", + "path": [ + "color", + "red" + ] + } + } +} +`; +/* end snapshot formats all should match json snapshot with fileHeaderTimestamp set */ + +snapshots["formats all should match json/asset snapshot with fileHeaderTimestamp set"] = +`{}`; +/* end snapshot formats all should match json/asset snapshot with fileHeaderTimestamp set */ + +snapshots["formats all should match json/nested snapshot with fileHeaderTimestamp set"] = +`{ + "color": { + "red": "#FF0000" + } +} +`; +/* end snapshot formats all should match json/nested snapshot with fileHeaderTimestamp set */ + +snapshots["formats all should match json/flat snapshot with fileHeaderTimestamp set"] = +`{ + "color_red": "#FF0000" +} +`; +/* end snapshot formats all should match json/flat snapshot with fileHeaderTimestamp set */ + +snapshots["formats all should match sketch/palette snapshot with fileHeaderTimestamp set"] = +`{ + "compatibleVersion": "1.0", + "pluginVersion": "1.1", + "colors": [ + "#FF0000" + ] +} +`; +/* end snapshot formats all should match sketch/palette snapshot with fileHeaderTimestamp set */ + +snapshots["formats all should match sketch/palette/v2 snapshot with fileHeaderTimestamp set"] = +`{ + "compatibleVersion": "2.0", + "pluginVersion": "2.2", + "colors": [ + { + "0": "#", + "1": "F", + "2": "F", + "3": "0", + "4": "0", + "5": "0", + "6": "0", + "name": "color_red" + } + ] +} +`; +/* end snapshot formats all should match sketch/palette/v2 snapshot with fileHeaderTimestamp set */ + +snapshots["formats all should match flutter/class.dart snapshot with fileHeaderTimestamp set"] = +` +// +// __output/ +// + +// Do not edit directly, this file was auto-generated. +// Generated on Sat, 01 Jan 2000 00:00:00 GMT + + + +import 'dart:ui'; + +class { + ._(); + + static const color_red = #FF0000; /* comment */ +}`; +/* end snapshot formats all should match flutter/class.dart snapshot with fileHeaderTimestamp set */ + diff --git a/__tests__/formats/__snapshots__/androidResources.test.snap.js b/__tests__/formats/__snapshots__/androidResources.test.snap.js index 0da19810e..062f56abd 100644 --- a/__tests__/formats/__snapshots__/androidResources.test.snap.js +++ b/__tests__/formats/__snapshots__/androidResources.test.snap.js @@ -5,8 +5,7 @@ snapshots["formats android/resources should match default snapshot"] = ` 12rem @@ -20,8 +19,7 @@ snapshots["formats android/resources with resourceType override should match sna ` 12rem @@ -35,8 +33,7 @@ snapshots["formats android/resources with resourceMap override should match snap ` #F2F3F4 diff --git a/__tests__/formats/__snapshots__/es6Constants.test.snap.js b/__tests__/formats/__snapshots__/es6Constants.test.snap.js index e0b5693f5..b1c3207b6 100644 --- a/__tests__/formats/__snapshots__/es6Constants.test.snap.js +++ b/__tests__/formats/__snapshots__/es6Constants.test.snap.js @@ -3,8 +3,7 @@ export const snapshots = {}; snapshots["formats javascript/es6 should be a valid JS file and match snapshot"] = `/** - * Do not edit directly - * Generated on Sat, 01 Jan 2000 00:00:00 GMT + * Do not edit directly, this file was auto-generated. */ export const red = "#EF5350"; diff --git a/__tests__/formats/__snapshots__/javascriptModule.test.snap.js b/__tests__/formats/__snapshots__/javascriptModule.test.snap.js index 73f12280e..e68258d9a 100644 --- a/__tests__/formats/__snapshots__/javascriptModule.test.snap.js +++ b/__tests__/formats/__snapshots__/javascriptModule.test.snap.js @@ -3,8 +3,7 @@ export const snapshots = {}; snapshots["formats javascript/module should be a valid JS file and match snapshot"] = `/** - * Do not edit directly - * Generated on Sat, 01 Jan 2000 00:00:00 GMT + * Do not edit directly, this file was auto-generated. */ module.exports = { diff --git a/__tests__/formats/__snapshots__/javascriptModuleFlat.test.snap.js b/__tests__/formats/__snapshots__/javascriptModuleFlat.test.snap.js index 3340f1d0b..aef449948 100644 --- a/__tests__/formats/__snapshots__/javascriptModuleFlat.test.snap.js +++ b/__tests__/formats/__snapshots__/javascriptModuleFlat.test.snap.js @@ -3,8 +3,7 @@ export const snapshots = {}; snapshots["formats javascript/module-flat should be a valid JS file and match snapshot"] = `/** - * Do not edit directly - * Generated on Sat, 01 Jan 2000 00:00:00 GMT + * Do not edit directly, this file was auto-generated. */ module.exports = { diff --git a/__tests__/formats/__snapshots__/javascriptObject.test.snap.js b/__tests__/formats/__snapshots__/javascriptObject.test.snap.js index d78ad82da..d5a44faf7 100644 --- a/__tests__/formats/__snapshots__/javascriptObject.test.snap.js +++ b/__tests__/formats/__snapshots__/javascriptObject.test.snap.js @@ -3,8 +3,7 @@ export const snapshots = {}; snapshots["formats javascript/object should be valid JS syntax and match snapshot"] = `/** - * Do not edit directly - * Generated on Sat, 01 Jan 2000 00:00:00 GMT + * Do not edit directly, this file was auto-generated. */ var foo = { diff --git a/__tests__/formats/__snapshots__/javascriptUmd.test.snap.js b/__tests__/formats/__snapshots__/javascriptUmd.test.snap.js index b9b139613..acc2dd985 100644 --- a/__tests__/formats/__snapshots__/javascriptUmd.test.snap.js +++ b/__tests__/formats/__snapshots__/javascriptUmd.test.snap.js @@ -3,8 +3,7 @@ export const snapshots = {}; snapshots["formats javascript/umd should be a valid JS file and match snapshot"] = `/** - * Do not edit directly - * Generated on Sat, 01 Jan 2000 00:00:00 GMT + * Do not edit directly, this file was auto-generated. */ (function(root, factory) { diff --git a/__tests__/formats/__snapshots__/lessIcons.test.snap.js b/__tests__/formats/__snapshots__/lessIcons.test.snap.js index 64438b2a3..f2387e3bf 100644 --- a/__tests__/formats/__snapshots__/lessIcons.test.snap.js +++ b/__tests__/formats/__snapshots__/lessIcons.test.snap.js @@ -1,10 +1,9 @@ /* @web/test-runner snapshot v1 */ export const snapshots = {}; -snapshots["formats less/icons should have a valid less syntax and match snapshot 1"] = +snapshots["formats less/icons should have a valid less syntax and match snapshot 1"] = ` -// Do not edit directly -// Generated on Sat, 01 Jan 2000 00:00:00 GMT +// Do not edit directly, this file was auto-generated. @content-icon-email: '\\E001'; .sd-icon.3d_rotation:before { content: @content-icon-email; }`; diff --git a/__tests__/formats/__snapshots__/lessVariables.test.snap.js b/__tests__/formats/__snapshots__/lessVariables.test.snap.js index 7de711e6e..817554b1a 100644 --- a/__tests__/formats/__snapshots__/lessVariables.test.snap.js +++ b/__tests__/formats/__snapshots__/lessVariables.test.snap.js @@ -4,8 +4,7 @@ export const snapshots = {}; snapshots["formats less/variables should have a valid less syntax and match snapshot 1"] = ` -// Do not edit directly -// Generated on Sat, 01 Jan 2000 00:00:00 GMT +// Do not edit directly, this file was auto-generated. @color-base-red-400: #EF5350; `; diff --git a/__tests__/formats/__snapshots__/scssIcons.test.snap.js b/__tests__/formats/__snapshots__/scssIcons.test.snap.js index 58ec198e0..6aee10f31 100644 --- a/__tests__/formats/__snapshots__/scssIcons.test.snap.js +++ b/__tests__/formats/__snapshots__/scssIcons.test.snap.js @@ -1,10 +1,9 @@ /* @web/test-runner snapshot v1 */ export const snapshots = {}; -snapshots["formats scss/icons should have a valid scss syntax and match snapshot 1"] = +snapshots["formats scss/icons should have a valid scss syntax and match snapshot 1"] = ` -// Do not edit directly -// Generated on Sat, 01 Jan 2000 00:00:00 GMT +// Do not edit directly, this file was auto-generated. $content-icon-email: '\\E001'; .sd-icon.three-d_rotation:before { content: $content-icon-email; }`; diff --git a/__tests__/formats/__snapshots__/scssMaps.test.snap.js b/__tests__/formats/__snapshots__/scssMaps.test.snap.js index 3ddecc214..3bc3c4183 100644 --- a/__tests__/formats/__snapshots__/scssMaps.test.snap.js +++ b/__tests__/formats/__snapshots__/scssMaps.test.snap.js @@ -4,8 +4,7 @@ export const snapshots = {}; snapshots["scss/map-flat snapshot"] = ` /** - * Do not edit directly - * Generated on Sat, 01 Jan 2000 00:00:00 GMT + * Do not edit directly, this file was auto-generated. */ $tokens: ( @@ -21,8 +20,7 @@ $tokens: ( snapshots["scss/map-deep snapshot"] = ` /** - * Do not edit directly - * Generated on Sat, 01 Jan 2000 00:00:00 GMT + * Do not edit directly, this file was auto-generated. */ $size-font-small: 12rem !default; diff --git a/__tests__/formats/__snapshots__/scssVariables.test.snap.js b/__tests__/formats/__snapshots__/scssVariables.test.snap.js index 4d3a38d99..75abfb3be 100644 --- a/__tests__/formats/__snapshots__/scssVariables.test.snap.js +++ b/__tests__/formats/__snapshots__/scssVariables.test.snap.js @@ -3,8 +3,7 @@ export const snapshots = {}; snapshots["formats scss/variables should have a valid scss syntax and match snapshot 1"] = ` -// Do not edit directly -// Generated on Sat, 01 Jan 2000 00:00:00 GMT +// Do not edit directly, this file was auto-generated. $color-base-red-400: #EF5350; `; diff --git a/__tests__/formats/__snapshots__/swiftFile.test.snap.js b/__tests__/formats/__snapshots__/swiftFile.test.snap.js index 240f8a84e..c5b67623c 100644 --- a/__tests__/formats/__snapshots__/swiftFile.test.snap.js +++ b/__tests__/formats/__snapshots__/swiftFile.test.snap.js @@ -1,14 +1,13 @@ /* @web/test-runner snapshot v1 */ export const snapshots = {}; -snapshots["formats ios-swift/any.swift should match default snapshot"] = +snapshots["formats ios-swift/any.swift should match default snapshot"] = ` // // __output/ // -// Do not edit directly -// Generated on Sat, 01 Jan 2000 00:00:00 GMT +// Do not edit directly, this file was auto-generated. import UIKit @@ -18,14 +17,13 @@ public class StyleDictionary { }`; /* end snapshot formats ios-swift/any.swift should match default snapshot */ -snapshots["formats ios-swift/any.swift with import override should match snapshot"] = +snapshots["formats ios-swift/any.swift with import override should match snapshot"] = ` // // __output/ // -// Do not edit directly -// Generated on Sat, 01 Jan 2000 00:00:00 GMT +// Do not edit directly, this file was auto-generated. import UIKit @@ -36,14 +34,13 @@ public class StyleDictionary { }`; /* end snapshot formats ios-swift/any.swift with import override should match snapshot */ -snapshots["formats ios-swift/any.swift with objectType override should match snapshot"] = +snapshots["formats ios-swift/any.swift with objectType override should match snapshot"] = ` // // __output/ // -// Do not edit directly -// Generated on Sat, 01 Jan 2000 00:00:00 GMT +// Do not edit directly, this file was auto-generated. import UIKit @@ -53,14 +50,13 @@ public struct StyleDictionary { }`; /* end snapshot formats ios-swift/any.swift with objectType override should match snapshot */ -snapshots["formats ios-swift/any.swift with access control override should match snapshot"] = +snapshots["formats ios-swift/any.swift with access control override should match snapshot"] = ` // // __output/ // -// Do not edit directly -// Generated on Sat, 01 Jan 2000 00:00:00 GMT +// Do not edit directly, this file was auto-generated. import UIKit diff --git a/__tests__/formats/__snapshots__/typeScriptEs6Declarations.test.snap.js b/__tests__/formats/__snapshots__/typeScriptEs6Declarations.test.snap.js index 5e0d92885..9a2481da5 100644 --- a/__tests__/formats/__snapshots__/typeScriptEs6Declarations.test.snap.js +++ b/__tests__/formats/__snapshots__/typeScriptEs6Declarations.test.snap.js @@ -3,8 +3,7 @@ export const snapshots = {}; snapshots["formats typescript/es6-declarations with outputStringLiterals should match snapshot"] = `/** - * Do not edit directly - * Generated on Sat, 01 Jan 2000 00:00:00 GMT + * Do not edit directly, this file was auto-generated. */ /** Used for errors */ diff --git a/__tests__/formats/all.test.js b/__tests__/formats/all.test.js index 2d3230a15..983b8aac5 100644 --- a/__tests__/formats/all.test.js +++ b/__tests__/formats/all.test.js @@ -14,6 +14,7 @@ import { expect } from 'chai'; import formats from '../../lib/common/formats.js'; import createFormatArgs from '../../lib/utils/createFormatArgs.js'; import flattenTokens from '../../lib/utils/flattenTokens.js'; +import { deepmerge } from '../../lib/utils/deepmerge.js'; const file = { destination: '__output/', @@ -54,6 +55,26 @@ describe('formats', async () => { await expect(output).to.matchSnapshot(); }); + it('should match ' + key + ' snapshot with fileHeaderTimestamp set', async () => { + const _file = deepmerge(file, { + options: { + formatting: { + fileHeaderTimestamp: true, + }, + }, + }); + const output = await format( + createFormatArgs({ + dictionary: { tokens, allTokens: flattenTokens(tokens) }, + file: _file, + platform: {}, + }), + {}, + _file, + ); + await expect(output).to.matchSnapshot(); + }); + it('should return ' + key + ' as a string', async () => { const output = await format( createFormatArgs({ diff --git a/docs/src/content/docs/reference/Hooks/Formats/predefined.md b/docs/src/content/docs/reference/Hooks/Formats/predefined.md index 1b06ff36b..8efa67946 100644 --- a/docs/src/content/docs/reference/Hooks/Formats/predefined.md +++ b/docs/src/content/docs/reference/Hooks/Formats/predefined.md @@ -12,12 +12,14 @@ You created a format and think it should be included? [Send us a PR](https://git Creates a CSS file with variable definitions based on the style dictionary -| Param | Type | Description | -| -------------------------- | ------------------------------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | -| `options` | `Object` | | -| `options.showFileHeader` | `boolean` | Whether or not to include a comment that has the build date. Defaults to `true` | -| `options.outputReferences` | `boolean \| OutputReferencesFunction` | Whether or not to keep [references](#references-in-output-files) (a -> b -> c) in the output. Defaults to `false`. Also allows passing a function to conditionally output references on a per token basis. | -| `options.selector` | `string` | Override the root css selector | +| Param | Type | Description | +| ---------------------------------- | ------------------------------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | +| `options` | `Object` | | +| `options.showFileHeader` | `boolean` | Whether or not to include a comment that has the build date. Defaults to `true` | +| `options.outputReferences` | `boolean \| OutputReferencesFunction` | Whether or not to keep [references](#references-in-output-files) (a -> b -> c) in the output. Defaults to `false`. Also allows passing a function to conditionally output references on a per token basis. | +| `options.outputReferenceFallbacks` | `boolean` | Whether or not to output css variable fallback values when using output references. You will want to pass this from the `options` object sent to the formatter function. | +| `options.selector` | `string` | Override the root css selector | +| `options.formatting` | `FormattingOptions` | Custom formatting properties that define parts of a declaration line in code. The configurable strings are: `prefix`, `indentation`, `separator`, `suffix`, `lineSeparator`, `fileHeaderTimestamp`, `header`, `footer`, `commentStyle` and `commentPosition`. Those are used to generate a line like this: `${indentation}${prefix}${token.name}${separator} ${prop.value}${suffix}`. The remaining formatting options are used for the fileHeader helper. | Example: @@ -52,12 +54,14 @@ Creates a SCSS file with a deep map based on the style dictionary. Name the map by adding a 'mapName' attribute on the file `options` object in your config. -| Param | Type | Description | -| -------------------------- | ------------------------------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | -| `options` | `Object` | | -| `options.outputReferences` | `boolean \| OutputReferencesFunction` | Whether or not to keep [references](#references-in-output-files) (a -> b -> c) in the output. Defaults to `false`. Also allows passing a function to conditionally output references on a per token basis. | -| `options.themeable` | `boolean` | Whether or not tokens should default to being themeable, if not otherwise specified per token. Defaults to `false`. | -| `options.mapName` | `string` | Name of your SCSS map. | +| Param | Type | Description | +| ---------------------------------- | ------------------------------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | +| `options` | `Object` | | +| `options.outputReferences` | `boolean \| OutputReferencesFunction` | Whether or not to keep [references](#references-in-output-files) (a -> b -> c) in the output. Defaults to `false`. Also allows passing a function to conditionally output references on a per token basis. | +| `options.outputReferenceFallbacks` | `boolean` | Whether or not to output css variable fallback values when using output references. You will want to pass this from the `options` object sent to the formatter function. | +| `options.themeable` | `boolean` | Whether or not tokens should default to being themeable, if not otherwise specified per token. Defaults to `false`. | +| `options.mapName` | `string` | Name of your SCSS map. | +| `options.formatting` | `FormattingOptions` | Custom formatting properties that define parts of a declaration line in code. The configurable strings are: `prefix`, `indentation`, `separator`, `suffix`, `lineSeparator`, `fileHeaderTimestamp`, `header`, `footer`, `commentStyle` and `commentPosition`. Those are used to generate a line like this: `${indentation}${prefix}${token.name}${separator} ${prop.value}${suffix}`. The remaining formatting options are used for the fileHeader helper. | Example: @@ -83,12 +87,14 @@ Creates a SCSS file with variable definitions based on the style dictionary. Add `!default` to any variable by setting a `themeable: true` attribute in the token's definition. -| Param | Type | Description | -| -------------------------- | ------------------------------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | -| `options` | `Object` | | -| `options.showFileHeader` | `boolean` | Whether or not to include a comment that has the build date. Defaults to `true` | -| `options.outputReferences` | `boolean \| OutputReferencesFunction` | Whether or not to keep [references](#references-in-output-files) (a -> b -> c) in the output. Defaults to `false`. Also allows passing a function to conditionally output references on a per token basis. | -| `options.themeable` | `boolean` | Whether or not tokens should default to being themeable, if not otherwise specified per token. Defaults to `false`. | +| Param | Type | Description | +| ---------------------------------- | ------------------------------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | +| `options` | `Object` | | +| `options.showFileHeader` | `boolean` | Whether or not to include a comment that has the build date. Defaults to `true` | +| `options.outputReferences` | `boolean \| OutputReferencesFunction` | Whether or not to keep [references](#references-in-output-files) (a -> b -> c) in the output. Defaults to `false`. Also allows passing a function to conditionally output references on a per token basis. | +| `options.outputReferenceFallbacks` | `boolean` | Whether or not to output css variable fallback values when using output references. You will want to pass this from the `options` object sent to the formatter function. | +| `options.themeable` | `boolean` | Whether or not tokens should default to being themeable, if not otherwise specified per token. Defaults to `false`. | +| `options.formatting` | `FormattingOptions` | Custom formatting properties that define parts of a declaration line in code. The configurable strings are: `prefix`, `indentation`, `separator`, `suffix`, `lineSeparator`, `fileHeaderTimestamp`, `header`, `footer`, `commentStyle` and `commentPosition`. Those are used to generate a line like this: `${indentation}${prefix}${token.name}${separator} ${prop.value}${suffix}`. The remaining formatting options are used for the fileHeader helper. | Example: @@ -118,11 +124,13 @@ $content-icon-email: '\E001'; Creates a LESS file with variable definitions based on the style dictionary -| Param | Type | Description | -| -------------------------- | ------------------------------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | -| `options` | `Object` | | -| `options.showFileHeader` | `boolean` | Whether or not to include a comment that has the build date. Defaults to `true` | -| `options.outputReferences` | `boolean \| OutputReferencesFunction` | Whether or not to keep [references](#references-in-output-files) (a -> b -> c) in the output. Defaults to `false`. Also allows passing a function to conditionally output references on a per token basis. | +| Param | Type | Description | +| ---------------------------------- | ------------------------------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | +| `options` | `Object` | | +| `options.showFileHeader` | `boolean` | Whether or not to include a comment that has the build date. Defaults to `true` | +| `options.outputReferences` | `boolean \| OutputReferencesFunction` | Whether or not to keep [references](#references-in-output-files) (a -> b -> c) in the output. Defaults to `false`. Also allows passing a function to conditionally output references on a per token basis. | +| `options.outputReferenceFallbacks` | `boolean` | Whether or not to output css variable fallback values when using output references. You will want to pass this from the `options` object sent to the formatter function. | +| `options.formatting` | `FormattingOptions` | Custom formatting properties that define parts of a declaration line in code. The configurable strings are: `prefix`, `indentation`, `separator`, `suffix`, `lineSeparator`, `fileHeaderTimestamp`, `header`, `footer`, `commentStyle` and `commentPosition`. Those are used to generate a line like this: `${indentation}${prefix}${token.name}${separator} ${prop.value}${suffix}`. The remaining formatting options are used for the fileHeader helper. | Example: diff --git a/docs/src/content/docs/reference/Utils/format-helpers.md b/docs/src/content/docs/reference/Utils/format-helpers.md index 8aafee3b4..d941cc74e 100644 --- a/docs/src/content/docs/reference/Utils/format-helpers.md +++ b/docs/src/content/docs/reference/Utils/format-helpers.md @@ -34,18 +34,18 @@ to use as the function on `dictionary.allTokens.map`. The formatting is configurable either by supplying a `format` option or a `formatting` object which uses: prefix, indentation, separator, suffix, and commentStyle. -| Param | Type | Description | -| ------------------------------------- | ------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | -| `options` | `Object` | A single argument to support named parameters and destructuring. | -| `options.outputReferences` | `boolean \| OutputReferencesFunction` | Whether or not to output references. You will want to pass this from the `options` object sent to the formatter function. Also allows passing a function to conditionally output references on a per token basis. | -| `options.outputReferenceFallbacks` | `boolean` | Whether or not to output css variable fallback values when using output references. You will want to pass this from the `options` object sent to the formatter function. | -| `options.dictionary` | `Dictionary` | Transformed Dictionary object containing allTokens, tokens and unfilteredTokens. | -| `options.dictionary.allTokens` | `TransformedToken[]` | Flattened array of all tokens, easiest to loop over and export to a flat format. | -| `options.dictionary.tokens` | `TransformedTokens` | All tokens, still in unflattened object format. | -| `options.dictionary.unfilteredTokens` | `TransformedTokens` | All tokens, still in unflattened object format, including tokens that were filtered out by filters. | -| `options.format` | `string` | Available formats are: 'css', 'sass', 'less', and 'stylus'. If you want to customize the format and can't use one of those predefined formats, use the `formatting` option | -| `options.formatting` | `FormattingOptions` | Custom formatting properties that define parts of a declaration line in code. The configurable strings are: prefix, indentation, separator, suffix, and commentStyle. Those are used to generate a line like this: `${indentation}${prefix}${prop.name}${separator} ${prop.value}${suffix}` | -| `options.themeable` | `boolean` | Whether tokens should default to being themeable. Defaults to false. | +| Param | Type | Description | +| ------------------------------------- | ------------------------------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | +| `options` | `Object` | A single argument to support named parameters and destructuring. | +| `options.outputReferences` | `boolean \| OutputReferencesFunction` | Whether or not to output references. You will want to pass this from the `options` object sent to the formatter function. Also allows passing a function to conditionally output references on a per token basis. | +| `options.outputReferenceFallbacks` | `boolean` | Whether or not to output css variable fallback values when using output references. You will want to pass this from the `options` object sent to the formatter function. | +| `options.dictionary` | `Dictionary` | Transformed Dictionary object containing allTokens, tokens and unfilteredTokens. | +| `options.dictionary.allTokens` | `TransformedToken[]` | Flattened array of all tokens, easiest to loop over and export to a flat format. | +| `options.dictionary.tokens` | `TransformedTokens` | All tokens, still in unflattened object format. | +| `options.dictionary.unfilteredTokens` | `TransformedTokens` | All tokens, still in unflattened object format, including tokens that were filtered out by filters. | +| `options.format` | `string` | Available formats are: 'css', 'sass', 'less', and 'stylus'. If you want to customize the format and can't use one of those predefined formats, use the `formatting` option | +| `options.formatting` | `FormattingOptions` | Custom formatting properties that define parts of a declaration line in code. The configurable strings are: `prefix`, `indentation`, `separator`, `suffix`, `lineSeparator`, `fileHeaderTimestamp`, `header`, `footer`, `commentStyle` and `commentPosition`. Those are used to generate a line like this: `${indentation}${prefix}${token.name}${separator} ${prop.value}${suffix}`. The remaining formatting options are used for the fileHeader helper. | +| `options.themeable` | `boolean` | Whether tokens should default to being themeable. Defaults to false. | Example: @@ -72,13 +72,13 @@ This is for creating the comment at the top of generated files with the generate It will use the custom file header if defined on the configuration, or use the default file header. -| Param | Type | Description | -| ------------------------- | -------------------------------- | --------------------------------------------------------------------------------------------------------------------------------------------- | -| `options` | `Object` | | -| `options.file` | [`File`](/reference/config#file) | The file object that is passed to the formatter. | -| `options.commentStyle` | `string` | The only options are 'short', 'xml' and 'long', which will use the `//`, `` or `/*` style comments respectively. Defaults to 'long'. | -| `options.commentPosition` | `string` | 'above' or 'inline', so either above the token or inline with the token | -| `options.formatting` | `Object` | Custom formatting properties that define parts of a comment in code. The configurable strings are: prefix, lineSeparator, header, and footer. | +| Param | Type | Description | +| ------------------------- | -------------------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------- | +| `options` | `Object` | | +| `options.file` | [`File`](/reference/config#file) | The file object that is passed to the formatter. | +| `options.commentStyle` | `string` | The only options are 'short', 'xml' and 'long', which will use the `//`, `` or `/*` style comments respectively. Defaults to 'long'. | +| `options.commentPosition` | `string` | 'above' or 'inline', so either above the token or inline with the token | +| `options.formatting` | `Object` | Custom formatting properties that define parts of a comment in code. The configurable strings are: prefix, lineSeparator, header, footer and fileHeaderTimestamp. | Example: @@ -94,6 +94,10 @@ StyleDictionary.registerFormat({ }); ``` +Use `options.formatting.fileHeaderTimestamp` set to `true` to create a fileHeader that contains a timestamp for when the file was created. +This used to be default behavior but was made opt-in to accompany the common use case of Style Dictionary running in Continuous Integration (CI) pipelines, +and not wanting to create redundant git diffs just because of the timestamp changing between versions. + --- ### formattedVariables diff --git a/docs/src/content/docs/version-4/migration.md b/docs/src/content/docs/version-4/migration.md index 9efd278f4..bb7c5337f 100644 --- a/docs/src/content/docs/version-4/migration.md +++ b/docs/src/content/docs/version-4/migration.md @@ -268,6 +268,44 @@ In v3, the following options were put on the file properties level itself next t } ``` +## fileHeader default timestamp + +For all formats using the `fileHeader` `formatHelpers` utility (most of the built-ins do), it will no longer display a timestamp in the fileHeader output by default. This is now an opt-in by setting `file.formatting.fileHeaderTimestamp` to `true`. The reason for making this opt-in now is that using Style Dictionary in the context of a CI (continuous integration) pipeline is a common use-case, and when running on pull request event, output files always show a diff in git due to the timestamp changing, which often just means that the diff is bloated by redundancy. + +To achieve the old behavior: + +```json title="config.json" ins={10} +{ + "platforms": { + "css": { + "files": [ + { + "destination": "variables.css", + "format": "css/variables", + "options": { + "formatting": { + "fileHeaderTimestamp": true + } + } + } + ] + } + } +} +``` + +or: + +```js title="config.js" ins={5} +import { fileHeader } from 'style-dictionary/utils'; + +const headerContent = await fileHeader({ + formatting: { + fileHeaderTimestamp: true, + }, +}); +``` + ## Types Style Dictionary is entirely strictly typed now, and there will be `.d.ts` files published next to every file, this means that if you import from one of Style Dictionary's entrypoints, you automatically get the types implicitly with it. This is a big win for people using TypeScript, as the majority of the codebase now has much better types, with much fewer `any`s. diff --git a/lib/common/formatHelpers/createPropertyFormatter.js b/lib/common/formatHelpers/createPropertyFormatter.js index bc38faa12..44dcba864 100644 --- a/lib/common/formatHelpers/createPropertyFormatter.js +++ b/lib/common/formatHelpers/createPropertyFormatter.js @@ -113,7 +113,7 @@ function addComment(to_ret_token, comment, options) { * @param {boolean} [options.outputReferenceFallbacks] - Whether or not to output css variable fallback values when using output references. You will want to pass this from the `options` object sent to the formatter function. * @param {Dictionary} options.dictionary - The dictionary object sent to the formatter function * @param {string} [options.format] - Available formats are: 'css', 'sass', 'less', and 'stylus'. If you want to customize the format and can't use one of those predefined formats, use the `formatting` option - * @param {Formatting} [options.formatting] - Custom formatting properties that define parts of a declaration line in code. The configurable strings are: prefix, indentation, separator, suffix, and commentStyle. Those are used to generate a line like this: `${indentation}${prefix}${token.name}${separator} ${token.value}${suffix}` + * @param {Formatting} [options.formatting] - Custom formatting properties that define parts of a declaration line in code. The configurable strings are: `prefix`, `indentation`, `separator`, `suffix`, `lineSeparator`, `fileHeaderTimestamp`, `header`, `footer`, `commentStyle` and `commentPosition`. Those are used to generate a line like this: `${indentation}${prefix}${token.name}${separator} ${prop.value}${suffix}`. The remaining formatting options are used for the fileHeader helper. * @param {boolean} [options.themeable] [false] - Whether tokens should default to being themeable. * @param {boolean} [options.usesDtcg] [false] - Whether DTCG token syntax should be uses. * @returns {(token: import('../../../types/DesignToken.d.ts').TransformedToken) => string} diff --git a/lib/common/formatHelpers/fileHeader.js b/lib/common/formatHelpers/fileHeader.js index 5a2ed0a4a..48eb9dab6 100644 --- a/lib/common/formatHelpers/fileHeader.js +++ b/lib/common/formatHelpers/fileHeader.js @@ -24,6 +24,7 @@ const defaultFormatting = { prefix: ` * `, header: `/**${lineSeparator}`, footer: `${lineSeparator} */${lineSeparator}${lineSeparator}`, + fileHeaderTimestamp: false, }; /** @@ -68,10 +69,17 @@ export default async function fileHeader({ file, commentStyle, formatting = {} } fn = file.options.fileHeader; } - // default header - const defaultHeader = [`Do not edit directly`, `Generated on ${new Date().toUTCString()}`]; + let { prefix, lineSeparator, header, footer, fileHeaderTimestamp } = Object.assign( + {}, + defaultFormatting, + formatting, + ); - let { prefix, lineSeparator, header, footer } = Object.assign({}, defaultFormatting, formatting); + // default header + const defaultHeader = [ + `Do not edit directly, this file was auto-generated.`, + ...(fileHeaderTimestamp ? [`Generated on ${new Date().toUTCString()}`] : []), + ]; if (commentStyle === 'short') { prefix = `// `; diff --git a/lib/common/formats.js b/lib/common/formats.js index daf52c61b..b85185b69 100644 --- a/lib/common/formats.js +++ b/lib/common/formats.js @@ -49,7 +49,8 @@ import plistTemplate from './templates/ios/plist.template.js'; /** * @typedef {import('../../types/Format.d.ts').Format} Format * @typedef {import('../../types/Format.d.ts').Formatter} Formatter - * @typedef {import('../../types/Format.d.ts').FormatterArguments} FormatOpts + * @typedef {import('../../types/Format.d.ts').FormatterArguments} FormatArgs + * @typedef {import('../../types/File').FormattingOptions} FormattingOptions * @typedef {import('../../types/Format.d.ts').OutputReferences} OutputReferences * @typedef {import('../../types/DesignToken.d.ts').TransformedToken} Token * @typedef {import('../../types/DesignToken.d.ts').TransformedTokens} Tokens @@ -59,6 +60,16 @@ import plistTemplate from './templates/ios/plist.template.js'; * @namespace Formats */ +/** + * remove prefix because the prefix option for createPropertyFormatting is not the same as the prefix inside header comment + * @param {FormattingOptions} [formatting] + */ +function getFormattingCloneWithoutPrefix(formatting) { + const formattingWithoutPrefix = structuredClone(formatting) ?? {}; + delete formattingWithoutPrefix.prefix; + return formattingWithoutPrefix; +} + /** * @type {Record} */ @@ -80,7 +91,10 @@ const formats = { 'css/variables': async function ({ dictionary, options = {}, file }) { const selector = options.selector ? options.selector : `:root`; const { outputReferences, outputReferenceFallbacks, usesDtcg, formatting } = options; - const header = await fileHeader({ file }); + const header = await fileHeader({ + file, + formatting: getFormattingCloneWithoutPrefix(formatting), + }); return ( header + `${selector} {\n` + @@ -103,7 +117,7 @@ const formats = { * * @memberof Formats * @kind member - * @param {FormatOpts} options + * @param {FormatArgs} options * @example * ```scss * $tokens: ( @@ -114,7 +128,12 @@ const formats = { */ 'scss/map-flat': async function ({ dictionary, options, file }) { const { allTokens } = dictionary; - const header = await fileHeader({ file, commentStyle: 'long' }); + const { formatting } = options; + const header = await fileHeader({ + file, + commentStyle: 'long', + formatting: getFormattingCloneWithoutPrefix(formatting), + }); return scssMapFlat({ allTokens, options, header }); }, @@ -141,9 +160,13 @@ const formats = { * ``` */ 'scss/map-deep': async function ({ dictionary, options, file }) { - const header = await fileHeader({ file, commentStyle: 'long' }); // Default the "themeable" option to true for backward compatibility. const { outputReferences, themeable = true, formatting, usesDtcg } = options; + const header = await fileHeader({ + file, + commentStyle: 'long', + formatting: getFormattingCloneWithoutPrefix(formatting), + }); return ( '\n' + header + @@ -175,7 +198,11 @@ const formats = { */ 'scss/variables': async function ({ dictionary, options, file }) { const { outputReferences, themeable = false, formatting, usesDtcg } = options; - const header = await fileHeader({ file, commentStyle: 'short' }); + const header = await fileHeader({ + file, + commentStyle: 'short', + formatting: getFormattingCloneWithoutPrefix(formatting), + }); return ( header + formattedVariables({ @@ -202,7 +229,12 @@ const formats = { * ``` */ 'scss/icons': async function ({ dictionary, options, file, platform }) { - const header = await fileHeader({ file, commentStyle: 'short' }); + const { formatting } = options; + const header = await fileHeader({ + file, + commentStyle: 'short', + formatting: getFormattingCloneWithoutPrefix(formatting), + }); return header + iconsWithPrefix('$', dictionary.allTokens, options, platform); }, @@ -219,7 +251,11 @@ const formats = { */ 'less/variables': async function ({ dictionary, options, file }) { const { outputReferences, formatting, usesDtcg } = options; - const header = await fileHeader({ file, commentStyle: 'short' }); + const header = await fileHeader({ + file, + commentStyle: 'short', + formatting: getFormattingCloneWithoutPrefix(formatting), + }); return ( header + formattedVariables({ format: 'less', dictionary, outputReferences, formatting, usesDtcg }) + @@ -239,7 +275,12 @@ const formats = { * ``` */ 'less/icons': async function ({ dictionary, options, file, platform }) { - const header = await fileHeader({ file, commentStyle: 'short' }); + const { formatting } = options; + const header = await fileHeader({ + file, + commentStyle: 'short', + formatting: getFormattingCloneWithoutPrefix(formatting), + }); return header + iconsWithPrefix('@', dictionary.allTokens, options, platform); }, @@ -257,7 +298,11 @@ const formats = { 'stylus/variables': async function ({ dictionary, options, file, platform }) { const { formatting, usesDtcg } = options; const outputReferences = !!platform.options?.outputReferences; - const header = await fileHeader({ file, commentStyle: 'short' }); + const header = await fileHeader({ + file, + commentStyle: 'short', + formatting: getFormattingCloneWithoutPrefix(formatting), + }); return ( header + formattedVariables({ format: 'stylus', dictionary, outputReferences, formatting, usesDtcg }) + @@ -283,8 +328,12 @@ const formats = { * } * ``` */ - 'javascript/module': async function ({ dictionary, file }) { - const header = await fileHeader({ file }); + 'javascript/module': async function ({ dictionary, file, options }) { + const { formatting } = options; + const header = await fileHeader({ + file, + formatting: getFormattingCloneWithoutPrefix(formatting), + }); return header + 'module.exports = ' + JSON.stringify(dictionary.tokens, null, 2) + ';\n'; }, @@ -301,7 +350,11 @@ const formats = { *``` */ 'javascript/module-flat': async function ({ dictionary, file, options }) { - const header = await fileHeader({ file }); + const { formatting } = options; + const header = await fileHeader({ + file, + formatting: getFormattingCloneWithoutPrefix(formatting), + }); return ( header + 'module.exports = ' + @@ -337,8 +390,12 @@ const formats = { * } * ``` */ - 'javascript/object': async function ({ dictionary, file }) { - const header = await fileHeader({ file }); + 'javascript/object': async function ({ dictionary, file, options }) { + const { formatting } = options; + const header = await fileHeader({ + file, + formatting: getFormattingCloneWithoutPrefix(formatting), + }); return ( header + 'var ' + @@ -379,9 +436,13 @@ const formats = { * })) * ``` */ - 'javascript/umd': async function ({ dictionary, file }) { + 'javascript/umd': async function ({ dictionary, file, options }) { const name = file.name || '_styleDictionary'; - const header = await fileHeader({ file }); + const { formatting } = options; + const header = await fileHeader({ + file, + formatting: getFormattingCloneWithoutPrefix(formatting), + }); return ( header + '(function(root, factory) {\n' + @@ -437,7 +498,11 @@ const formats = { * ``` */ 'javascript/es6': async function ({ dictionary, file, options }) { - const header = await fileHeader({ file }); + const { formatting } = options; + const header = await fileHeader({ + file, + formatting: getFormattingCloneWithoutPrefix(formatting), + }); return ( header + dictionary.allTokens @@ -489,7 +554,11 @@ const formats = { * ``` */ 'typescript/es6-declarations': async function ({ dictionary, file, options }) { - const header = await fileHeader({ file }); + const { formatting } = options; + const header = await fileHeader({ + file, + formatting: getFormattingCloneWithoutPrefix(formatting), + }); return ( header + dictionary.allTokens @@ -596,7 +665,11 @@ const formats = { [key: string]: any; }`; - const header = await fileHeader({ file }); + const { formatting } = options; + const header = await fileHeader({ + file, + formatting: getFormattingCloneWithoutPrefix(formatting), + }); const output = header + `export default ${moduleName}; @@ -635,7 +708,12 @@ declare const ${moduleName}: ${JSON.stringify(treeWalker(dictionary.tokens), nul * ``` */ 'android/resources': async function ({ dictionary, file, options }) { - const header = await fileHeader({ file, commentStyle: 'xml' }); + const { formatting } = options; + const header = await fileHeader({ + file, + commentStyle: 'xml', + formatting: getFormattingCloneWithoutPrefix(formatting), + }); return androidResources({ dictionary, file, header, options }); }, @@ -664,7 +742,12 @@ declare const ${moduleName}: ${JSON.stringify(treeWalker(dictionary.tokens), nul * ``` */ 'android/colors': async function ({ dictionary, options, file }) { - const header = await fileHeader({ file, commentStyle: 'xml' }); + const { formatting } = options; + const header = await fileHeader({ + file, + commentStyle: 'xml', + formatting: getFormattingCloneWithoutPrefix(formatting), + }); return androidColors({ dictionary, options, header }); }, @@ -693,7 +776,12 @@ declare const ${moduleName}: ${JSON.stringify(treeWalker(dictionary.tokens), nul * ``` */ 'android/dimens': async function ({ dictionary, options, file }) { - const header = await fileHeader({ file, commentStyle: 'xml' }); + const { formatting } = options; + const header = await fileHeader({ + file, + commentStyle: 'xml', + formatting: getFormattingCloneWithoutPrefix(formatting), + }); return androidDimens({ dictionary, options, header }); }, @@ -722,7 +810,12 @@ declare const ${moduleName}: ${JSON.stringify(treeWalker(dictionary.tokens), nul * ``` */ 'android/fontDimens': async function ({ dictionary, options, file }) { - const header = await fileHeader({ file, commentStyle: 'xml' }); + const { formatting } = options; + const header = await fileHeader({ + file, + commentStyle: 'xml', + formatting: getFormattingCloneWithoutPrefix(formatting), + }); return androidFontDimens({ dictionary, options, header }); }, @@ -753,7 +846,12 @@ declare const ${moduleName}: ${JSON.stringify(treeWalker(dictionary.tokens), nul * ``` */ 'android/integers': async function ({ dictionary, options, file }) { - const header = await fileHeader({ file, commentStyle: 'xml' }); + const { formatting } = options; + const header = await fileHeader({ + file, + commentStyle: 'xml', + formatting: getFormattingCloneWithoutPrefix(formatting), + }); return androidIntegers({ dictionary, options, header }); }, @@ -783,7 +881,12 @@ declare const ${moduleName}: ${JSON.stringify(treeWalker(dictionary.tokens), nul * ``` */ 'android/strings': async function ({ dictionary, options, file }) { - const header = await fileHeader({ file, commentStyle: 'xml' }); + const { formatting } = options; + const header = await fileHeader({ + file, + commentStyle: 'xml', + formatting: getFormattingCloneWithoutPrefix(formatting), + }); return androidStrings({ dictionary, options, header }); }, @@ -799,7 +902,7 @@ declare const ${moduleName}: ${JSON.stringify(treeWalker(dictionary.tokens), nul * @property {String[]} [composeObjectOpts.import=['androidx.compose.ui.graphics.Color', 'androidx.compose.ui.unit.*']] - Modules to import. Can be a string or array of strings * @property {boolean} [composeObjectOpts.showFileHeader=true] - Whether or not to include a comment that has the build date * @property {OutputReferences} [composeObjectOpts.outputReferences=false] - Whether or not to keep [references](/#/formats?id=references-in-output-files) (a -> b -> c) in the output. - * @param {FormatOpts & { options?: composeObjectOpts }} options + * @param {FormatArgs & { options?: composeObjectOpts }} options * @example * ```kotlin * package com.example.tokens; @@ -833,7 +936,11 @@ declare const ${moduleName}: ${JSON.stringify(treeWalker(dictionary.tokens), nul } options = setComposeObjectProperties(options); - const header = await fileHeader({ file, commentStyle: 'short' }); + const header = await fileHeader({ + file, + commentStyle: 'short', + formatting: getFormattingCloneWithoutPrefix(formatting), + }); return composeObject({ allTokens: sortedTokens, options, formatProperty, header }); }, @@ -854,7 +961,12 @@ declare const ${moduleName}: ${JSON.stringify(treeWalker(dictionary.tokens), nul * ``` */ 'ios/macros': async function ({ dictionary, options, file }) { - const header = await fileHeader({ file, commentStyle: 'short' }); + const { formatting } = options; + const header = await fileHeader({ + file, + commentStyle: 'short', + formatting: getFormattingCloneWithoutPrefix(formatting), + }); return macrosTemplate({ dictionary, options, file, header }); }, @@ -866,7 +978,12 @@ declare const ${moduleName}: ${JSON.stringify(treeWalker(dictionary.tokens), nul * @todo Fix this template and add example and usage */ 'ios/plist': async function ({ dictionary, options, file }) { - const header = await fileHeader({ file, commentStyle: 'xml' }); + const { formatting } = options; + const header = await fileHeader({ + file, + commentStyle: 'xml', + formatting: getFormattingCloneWithoutPrefix(formatting), + }); return plistTemplate({ dictionary, options, header }); }, @@ -878,7 +995,12 @@ declare const ${moduleName}: ${JSON.stringify(treeWalker(dictionary.tokens), nul * @todo Add example and usage */ 'ios/singleton.m': async function ({ dictionary, options, file }) { - const header = await fileHeader({ file, commentStyle: 'short' }); + const { formatting } = options; + const header = await fileHeader({ + file, + commentStyle: 'short', + formatting: getFormattingCloneWithoutPrefix(formatting), + }); return iosSingletonM({ dictionary, options, file, header }); }, @@ -890,7 +1012,12 @@ declare const ${moduleName}: ${JSON.stringify(treeWalker(dictionary.tokens), nul * @todo Add example and usage */ 'ios/singleton.h': async function ({ file, options }) { - const header = await fileHeader({ file, commentStyle: 'short' }); + const { formatting } = options; + const header = await fileHeader({ + file, + commentStyle: 'short', + formatting: getFormattingCloneWithoutPrefix(formatting), + }); return iosSingletonH({ file, options, header }); }, @@ -902,7 +1029,12 @@ declare const ${moduleName}: ${JSON.stringify(treeWalker(dictionary.tokens), nul * @todo Add example and usage */ 'ios/static.h': async function ({ dictionary, file, options }) { - const header = await fileHeader({ file, commentStyle: 'short' }); + const { formatting } = options; + const header = await fileHeader({ + file, + commentStyle: 'short', + formatting: getFormattingCloneWithoutPrefix(formatting), + }); return iosStaticH({ dictionary, file, options, header }); }, @@ -914,7 +1046,12 @@ declare const ${moduleName}: ${JSON.stringify(treeWalker(dictionary.tokens), nul * @todo Add example and usage */ 'ios/static.m': async function ({ dictionary, options, file }) { - const header = await fileHeader({ file, commentStyle: 'short' }); + const { formatting } = options; + const header = await fileHeader({ + file, + commentStyle: 'short', + formatting: getFormattingCloneWithoutPrefix(formatting), + }); return iosStaticM({ dictionary, options, file, header }); }, @@ -926,7 +1063,12 @@ declare const ${moduleName}: ${JSON.stringify(treeWalker(dictionary.tokens), nul * @todo Add example and usage */ 'ios/colors.h': async function ({ dictionary, options, file }) { - const header = await fileHeader({ file, commentStyle: 'short' }); + const { formatting } = options; + const header = await fileHeader({ + file, + commentStyle: 'short', + formatting: getFormattingCloneWithoutPrefix(formatting), + }); return iosColorsH({ dictionary, file, options, header }); }, @@ -938,7 +1080,12 @@ declare const ${moduleName}: ${JSON.stringify(treeWalker(dictionary.tokens), nul * @todo Add example and usage */ 'ios/colors.m': async function ({ dictionary, options, file }) { - const header = await fileHeader({ file, commentStyle: 'short' }); + const { formatting } = options; + const header = await fileHeader({ + file, + commentStyle: 'short', + formatting: getFormattingCloneWithoutPrefix(formatting), + }); return iosColorsM({ dictionary, options, file, header }); }, @@ -950,7 +1097,12 @@ declare const ${moduleName}: ${JSON.stringify(treeWalker(dictionary.tokens), nul * @todo Add example and usage */ 'ios/strings.h': async function ({ dictionary, file, options }) { - const header = await fileHeader({ file, commentStyle: 'short' }); + const { formatting } = options; + const header = await fileHeader({ + file, + commentStyle: 'short', + formatting: getFormattingCloneWithoutPrefix(formatting), + }); return iosStringsH({ dictionary, file, options, header }); }, @@ -962,7 +1114,12 @@ declare const ${moduleName}: ${JSON.stringify(treeWalker(dictionary.tokens), nul * @todo Add example and usage */ 'ios/strings.m': async function ({ dictionary, options, file }) { - const header = await fileHeader({ file, commentStyle: 'short' }); + const { formatting } = options; + const header = await fileHeader({ + file, + commentStyle: 'short', + formatting: getFormattingCloneWithoutPrefix(formatting), + }); return iosStringsM({ dictionary, options, file, header }); }, @@ -977,7 +1134,7 @@ declare const ${moduleName}: ${JSON.stringify(treeWalker(dictionary.tokens), nul * @property {String} [iosSwiftClassOpts.className] - The name of the generated Swift class * @property {boolean} [iosSwiftClassOpts.showFileHeader=true] - Whether or not to include a comment that has the build date * @property {OutputReferences} [iosSwiftClassOpts.outputReferences=false] - Whether or not to keep [references](/#/formats?id=references-in-output-files) (a -> b -> c) in the output. - * @param {FormatOpts & { options?: iosSwiftClassOpts }} options + * @param {FormatArgs & { options?: iosSwiftClassOpts }} options * @example * ```swift * public class StyleDictionary { @@ -1005,7 +1162,11 @@ declare const ${moduleName}: ${JSON.stringify(treeWalker(dictionary.tokens), nul } else { sortedTokens = [...allTokens].sort(sortByName); } - const header = await fileHeader({ file, commentStyle: 'short' }); + const header = await fileHeader({ + file, + commentStyle: 'short', + formatting: getFormattingCloneWithoutPrefix(formatting), + }); return iosSwiftAny({ allTokens: sortedTokens, file, options, formatProperty, header }); }, @@ -1019,7 +1180,7 @@ declare const ${moduleName}: ${JSON.stringify(treeWalker(dictionary.tokens), nul * @property {String[]} [iosSwiftEnumOpts.import='UIKit'] - Modules to import. Can be a string or array of strings * @property {boolean} [iosSwiftEnumOpts.showFileHeader=true] - Whether or not to include a comment that has the build date * @property {OutputReferences} [iosSwiftEnumOpts.outputReferences=false] - Whether or not to keep [references](/#/formats?id=references-in-output-files) (a -> b -> c) in the output. - * @param {FormatOpts & { options?: iosSwiftEnumOpts }} options + * @param {FormatArgs & { options?: iosSwiftEnumOpts }} options * @example * ```swift * public enum StyleDictionary { @@ -1047,7 +1208,11 @@ declare const ${moduleName}: ${JSON.stringify(treeWalker(dictionary.tokens), nul } else { sortedTokens = [...allTokens].sort(sortByName); } - const header = await fileHeader({ file, commentStyle: 'short' }); + const header = await fileHeader({ + file, + commentStyle: 'short', + formatting: getFormattingCloneWithoutPrefix(formatting), + }); return iosSwiftAny({ allTokens: sortedTokens, file, options, formatProperty, header }); }, @@ -1069,7 +1234,7 @@ declare const ${moduleName}: ${JSON.stringify(treeWalker(dictionary.tokens), nul * @property {string} [iosSwiftAnyOpts.objectType='class'] - The type of the generated Swift object * @property {boolean} [iosSwiftAnyOpts.showFileHeader=true] - Whether or not to include a comment that has the build date * @property {OutputReferences} [iosSwiftAnyOpts.outputReferences=false] - Whether or not to keep [references](/#/formats?id=references-in-output-files) (a -> b -> c) in the output. - * @param {FormatOpts & { options?: iosSwiftAnyOpts }} options + * @param {FormatArgs & { options?: iosSwiftAnyOpts }} options * @example * ```swift * import UIKit @@ -1100,7 +1265,11 @@ declare const ${moduleName}: ${JSON.stringify(treeWalker(dictionary.tokens), nul } else { sortedTokens = [...allTokens].sort(sortByName); } - const header = await fileHeader({ file, commentStyle: 'short' }); + const header = await fileHeader({ + file, + commentStyle: 'short', + formatting: getFormattingCloneWithoutPrefix(formatting), + }); return iosSwiftAny({ allTokens: sortedTokens, file, options, formatProperty, header }); }, @@ -1289,7 +1458,7 @@ declare const ${moduleName}: ${JSON.stringify(treeWalker(dictionary.tokens), nul * @typedef {Object} flutterClassOpts * @property {boolean} [flutterClassOpts.showFileHeader=true] - Whether or not to include a comment that has the build date * @property {OutputReferences} [flutterClassOpts.outputReferences=false] - Whether or not to keep [references](/#/formats?id=references-in-output-files) (a -> b -> c) in the output. - * @param {FormatOpts & { options?: flutterClassOpts }} options + * @param {FormatArgs & { options?: flutterClassOpts }} options * @example * ```dart * import 'package:flutter/material.dart'; @@ -1318,7 +1487,11 @@ declare const ${moduleName}: ${JSON.stringify(treeWalker(dictionary.tokens), nul } else { sortedTokens = [...allTokens].sort(sortByName); } - const header = await fileHeader({ file, commentStyle: 'short' }); + const header = await fileHeader({ + file, + commentStyle: 'short', + formatting: getFormattingCloneWithoutPrefix(formatting), + }); return flutterClassDart({ allTokens: sortedTokens, file, options, formatProperty, header }); }, }; diff --git a/types/Config.d.ts b/types/Config.d.ts index 13ae70efa..f427c3837 100644 --- a/types/Config.d.ts +++ b/types/Config.d.ts @@ -13,7 +13,7 @@ import type { DesignTokens, TransformedToken } from './DesignToken.d.ts'; import type { Filter, Matcher } from './Filter.d.ts'; -import type { FileHeader, File } from './File.d.ts'; +import type { FileHeader, File, FormattingOptions } from './File.d.ts'; import type { Parser } from './Parser.d.ts'; import type { Preprocessor } from './Preprocessor.d.ts'; import type { Transform } from './Transform.d.ts'; @@ -24,6 +24,8 @@ export interface LocalOptions { showFileHeader?: boolean; fileHeader?: string | FileHeader; outputReferences?: OutputReferences; + outputReferenceFallbacks?: boolean; + formatting?: FormattingOptions; [key: string]: any; } diff --git a/types/File.d.ts b/types/File.d.ts index 358172288..879158b78 100644 --- a/types/File.d.ts +++ b/types/File.d.ts @@ -13,6 +13,7 @@ export interface FormattingOptions { commentPosition?: 'above' | 'inline'; indentation?: string; separator?: string; + fileHeaderTimestamp?: boolean; } export type FileHeader = (defaultMessage: string[]) => Promise | string[];