Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
57 changes: 25 additions & 32 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

17 changes: 16 additions & 1 deletion packages/ui-scripts/lib/build/generate-all-tokens.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
*/

import path from 'path'
import fs from 'fs'
import { error } from '@instructure/command-utils'
import { handleMapJSTokensToSource } from '../utils/handle-map-js-tokens-to-source.js'
import { handleGenerateTokens } from '../utils/handle-generate-tokens.js'
Expand Down Expand Up @@ -90,7 +91,21 @@ export default {
? path.join(themePath, outputDir, themeKey)
: path.join(themePath, outputDir)
const sourcePath = path.join(outputPath, 'source.json')

// this is just a debug code to find the JSON error here that occurs only in CI
// eslint-disable-next-line no-console
console.log(
'!!!!! starting',
themeKey,
sourceTokens,
outputPath,
sourcePath,
fs.existsSync(sourcePath)
)
// eslint-disable-next-line no-console
console.log(
'!!!! styleDictionarySource',
JSON.stringify(styleDictionarySource)?.substring(0, 400)
)
generators.push(
handleGenerateTokens({
themeKey,
Expand Down
86 changes: 47 additions & 39 deletions packages/ui-scripts/lib/utils/handle-generate-tokens.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,53 +22,61 @@
* SOFTWARE.
*/

import fse from 'fs-extra'
import path from 'path'
import StyleDictionary from 'style-dictionary'
import fs from 'fs'

export async function handleGenerateTokens({
themeKey,
sourcePath,
styleDictionarySource,
outputPath
}) {
return fse
.outputFile(sourcePath, JSON.stringify(styleDictionarySource))
Comment on lines -35 to -36
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The error was likely that this was not created in some rare cases, I dont know why. I've replaced it with just native Node code

.then(() => {
const dictionary = new StyleDictionary({
source: [sourcePath],
platforms: {
scss: {
transformGroup: 'scss',
prefix: 'instui-' + themeKey,
buildPath: path.join(outputPath, 'scss/'),
files: [
{
destination: '_variables.scss',
format: 'scss/variables'
}
]
const dir = path.dirname(sourcePath)
if (!fs.existsSync(dir)) {
fs.mkdirSync(dir, { recursive: true })
}
fs.writeFileSync(sourcePath, JSON.stringify(styleDictionarySource))
// this is just a debug code to find the JSON error here that occurs only in CI
// eslint-disable-next-line no-console
console.log(
'!!!! handleGenerateTokens',
sourcePath,
fs.existsSync(sourcePath),
JSON.stringify(styleDictionarySource)?.substring(0, 400)
)
const dictionary = new StyleDictionary({
source: [sourcePath],
platforms: {
scss: {
transformGroup: 'scss',
prefix: 'instui-' + themeKey,
buildPath: path.join(outputPath, 'scss/'),
files: [
{
destination: '_variables.scss',
format: 'scss/variables'
}
// TODO: Revisit the best way to distribute tokens for vanilla JS
// js: {
// transformGroup: 'js',
// buildPath: path.join(outputPath, 'js/'),
// files: [
// {
// destination: 'umd.js',
// format: 'javascript/umd'
// },
// {
// destination: 'es6.js',
// format: 'javascript/es6'
// }
// ]
// }
}
})
return dictionary.buildAllPlatforms()
})
.then((builds) => {
return builds
})
]
}
// TODO: Revisit the best way to distribute tokens for vanilla JS
// js: {
// transformGroup: 'js',
// buildPath: path.join(outputPath, 'js/'),
// files: [
// {
// destination: 'umd.js',
// format: 'javascript/umd'
// },
// {
// destination: 'es6.js',
// format: 'javascript/es6'
// }
// ]
// }
}
})
dictionary.buildAllPlatforms().then((builds) => {
return builds
})
}
3 changes: 1 addition & 2 deletions packages/ui-scripts/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -26,15 +26,14 @@
"@lerna/project": "^6.4.1",
"dotenv": "^16.4.7",
"find-up": "^7.0.0",
"fs-extra": "^11.2.0",
"http-server": "^14.1.1",
"jscodeshift": "^0.16.1",
"karma-cli": "^2.0.0",
"lerna": "^8.1.9",
"lodash.isplainobject": "^4.0.6",
"mocha": "^10.7.3",
"semver": "^7.6.3",
"style-dictionary": "4.1.2",
"style-dictionary": "4.4.0",
"webpack-cli": "^5.1.4",
"webpack-dev-server": "^5.1.0",
"yargs": "^17.7.2"
Expand Down
Loading