-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add delete and restore functionality for tokens
- Loading branch information
Carlos Viteri
committed
Dec 23, 2024
1 parent
ce3cd24
commit 5094ae6
Showing
10 changed files
with
1,085 additions
and
661 deletions.
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,60 +1,60 @@ | ||
import fs from 'fs-extra'; | ||
import concat from 'concat'; | ||
import path from 'path'; | ||
import { getDirname } from '../utils.mjs'; | ||
import fs from 'fs-extra' | ||
import concat from 'concat' | ||
import path from 'path' | ||
import { getDirname } from '../utils.mjs' | ||
|
||
const __dirname = getDirname(import.meta.url); | ||
const __dirname = getDirname(import.meta.url) | ||
|
||
export const concatFiles = (StyleDictionary) => { | ||
StyleDictionary.registerAction({ | ||
name: 'concat-files', | ||
do: (dictionary, config) => { | ||
try { | ||
// Read files from the specified build path | ||
const buildPath = path.join(__dirname, '../../', config.buildPath); | ||
const files = fs.readdirSync(buildPath); | ||
const buildPath = path.join(__dirname, '../../', config.buildPath) | ||
const files = fs.readdirSync(buildPath) | ||
|
||
if (files.length === 0) { | ||
console.warn('No files found in the build path.'); | ||
return; | ||
console.warn('No files found in the build path.') | ||
return | ||
} | ||
|
||
// Determine the file extension from the first file | ||
const extension = path.extname(files[0]); | ||
const allPaths = files.map(f => path.join(buildPath, f)); | ||
const concatPaths = allPaths.filter(p => !path.basename(p).includes('no_concat')); | ||
const noConcatPaths = allPaths.filter(p => path.basename(p).includes('no_concat')); | ||
const extension = path.extname(files[0]) | ||
const allPaths = files.map(f => path.join(buildPath, f)) | ||
const concatPaths = allPaths.filter(p => !path.basename(p).includes('no_concat')) | ||
const noConcatPaths = allPaths.filter(p => path.basename(p).includes('no_concat')) | ||
|
||
// Rename files with 'no_concat' in their name | ||
noConcatPaths.forEach(p => { | ||
const newPath = p.replace('.no_concat', ''); | ||
fs.renameSync(p, newPath); | ||
}); | ||
const newPath = p.replace('.no_concat', '') | ||
fs.renameSync(p, newPath) | ||
}) | ||
|
||
// Concatenate files | ||
concat(concatPaths).then((r) => { | ||
const outFile = path.join(__dirname, '../../', config.buildPath, `cdr-tokens${extension}`); | ||
fs.outputFileSync(outFile, r); | ||
}); | ||
const outFile = path.join(__dirname, '../../', config.buildPath, `cdr-tokens${extension}`) | ||
fs.outputFileSync(outFile, r) | ||
}) | ||
|
||
// Remove concatenated files | ||
concatPaths.forEach(p => { | ||
fs.removeSync(p); | ||
}); | ||
fs.removeSync(p) | ||
}) | ||
|
||
console.log('Successfully removed concatenated files'); | ||
console.log('Successfully removed concatenated files') | ||
} catch (error) { | ||
console.error('Error during file concatenation process:', error); | ||
console.error('Error during file concatenation process:', error) | ||
} | ||
}, | ||
undo: (dictionary, config) => { | ||
try { | ||
const buildPath = path.join(__dirname, '../../', config.buildPath); | ||
fs.removeSync(buildPath); | ||
console.log(`Successfully removed ${buildPath}`); | ||
const buildPath = path.join(__dirname, '../../', config.buildPath) | ||
fs.removeSync(buildPath) | ||
console.log(`Successfully removed ${buildPath}`) | ||
} catch (error) { | ||
console.error('Error removing build path:', error); | ||
console.error('Error removing build path:', error) | ||
} | ||
} | ||
}); | ||
}; | ||
}) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,39 +1,39 @@ | ||
import fs from 'fs-extra'; | ||
import path from 'path'; | ||
import { getDirname } from '../utils.mjs'; | ||
import fs from 'fs-extra' | ||
import path from 'path' | ||
import { getDirname } from '../utils.mjs' | ||
|
||
const __dirname = getDirname(import.meta.url); | ||
const __dirname = getDirname(import.meta.url) | ||
|
||
export const includeDeprecateScss = (StyleDictionary) => { | ||
// Register custom action for Style Dictionary | ||
StyleDictionary.registerAction({ | ||
name: 'include-deprecate-scss', | ||
do: (dictionary, config) => { | ||
try { | ||
const deprecateScss = path.join(__dirname, '../utilities/deprecate.scss'); | ||
const outputDir = path.join(__dirname, '../../', config.buildPath); | ||
const outputFile = path.join(outputDir, 'deprecate.scss'); | ||
const deprecateScss = path.join(__dirname, '../utilities/deprecate.scss') | ||
const outputDir = path.join(__dirname, '../../', config.buildPath) | ||
const outputFile = path.join(outputDir, 'deprecate.scss') | ||
|
||
// Ensure the output directory exists | ||
fs.ensureDirSync(outputDir); | ||
fs.ensureDirSync(outputDir) | ||
|
||
// Copy the SCSS file | ||
fs.copyFileSync(deprecateScss, outputFile); | ||
console.log(`Successfully copied to ${outputFile}`); | ||
fs.copyFileSync(deprecateScss, outputFile) | ||
console.log(`Successfully copied to ${outputFile}`) | ||
} catch (error) { | ||
console.error('Error including deprecate SCSS:', error); | ||
console.error('Error including deprecate SCSS:', error) | ||
} | ||
}, | ||
undo: (dictionary, config) => { | ||
try { | ||
const outputDir = path.join(__dirname, '../../', config.buildPath); | ||
const outputDir = path.join(__dirname, '../../', config.buildPath) | ||
|
||
// Remove the output directory and its contents | ||
fs.removeSync(outputDir); | ||
console.log(`Successfully removed ${outputDir}`); | ||
fs.removeSync(outputDir) | ||
console.log(`Successfully removed ${outputDir}`) | ||
} catch (error) { | ||
console.error('Error removing deprecate SCSS directory:', error); | ||
console.error('Error removing deprecate SCSS directory:', error) | ||
} | ||
} | ||
}); | ||
}) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,38 +1,38 @@ | ||
import fs from 'fs-extra'; | ||
import path from 'path'; | ||
import { getDirname } from '../utils.mjs'; | ||
import fs from 'fs-extra' | ||
import path from 'path' | ||
import { getDirname } from '../utils.mjs' | ||
|
||
const __dirname = getDirname(import.meta.url); | ||
const __dirname = getDirname(import.meta.url) | ||
|
||
export const includeDisplayLess = (StyleDictionary) => { | ||
StyleDictionary.registerAction({ | ||
name: 'include-display-less', | ||
do: (dictionary, config) => { | ||
try { | ||
const lessFile = path.join(__dirname, '../utilities/display.less'); | ||
const outputDir = path.join(__dirname, '../../', config.buildPath); | ||
const outputFile = path.join(outputDir, 'display.less'); | ||
const lessFile = path.join(__dirname, '../utilities/display.less') | ||
const outputDir = path.join(__dirname, '../../', config.buildPath) | ||
const outputFile = path.join(outputDir, 'display.less') | ||
|
||
// Ensure the output directory exists | ||
fs.ensureDirSync(outputDir); | ||
fs.ensureDirSync(outputDir) | ||
|
||
// Copy the LESS file to the output directory | ||
fs.copyFileSync(lessFile, outputFile); | ||
console.log(`Successfully copied ${lessFile} to ${outputFile}`); | ||
fs.copyFileSync(lessFile, outputFile) | ||
console.log(`Successfully copied ${lessFile} to ${outputFile}`) | ||
} catch (error) { | ||
console.error('Error including display LESS file:', error); | ||
console.error('Error including display LESS file:', error) | ||
} | ||
}, | ||
undo: (dictionary, config) => { | ||
try { | ||
const outputDir = path.join(__dirname, '../../', config.buildPath); | ||
const outputDir = path.join(__dirname, '../../', config.buildPath) | ||
|
||
// Remove the output directory and its contents | ||
fs.removeSync(outputDir); | ||
console.log(`Successfully removed ${outputDir}`); | ||
fs.removeSync(outputDir) | ||
console.log(`Successfully removed ${outputDir}`) | ||
} catch (error) { | ||
console.error('Error removing display LESS file directory:', error); | ||
console.error('Error removing display LESS file directory:', error) | ||
} | ||
} | ||
}); | ||
}; | ||
}) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,38 +1,38 @@ | ||
import fs from 'fs-extra'; | ||
import path from 'path'; | ||
import { getDirname } from '../utils.mjs'; | ||
import fs from 'fs-extra' | ||
import path from 'path' | ||
import { getDirname } from '../utils.mjs' | ||
|
||
const __dirname = getDirname(import.meta.url); | ||
const __dirname = getDirname(import.meta.url) | ||
|
||
export const includeDisplayScss = (StyleDictionary) => { | ||
StyleDictionary.registerAction({ | ||
name: 'include-display-scss', | ||
do: (dictionary, config) => { | ||
try { | ||
const scssFile = path.join(__dirname, '../utilities/display.scss'); | ||
const outputDir = path.join(__dirname, '../../', config.buildPath); | ||
const outputFile = path.join(outputDir, 'display.scss'); | ||
const scssFile = path.join(__dirname, '../utilities/display.scss') | ||
const outputDir = path.join(__dirname, '../../', config.buildPath) | ||
const outputFile = path.join(outputDir, 'display.scss') | ||
|
||
// Ensure the output directory exists | ||
fs.ensureDirSync(outputDir); | ||
fs.ensureDirSync(outputDir) | ||
|
||
// Copy the SCSS file to the output directory | ||
fs.copyFileSync(scssFile, outputFile); | ||
console.log(`Successfully copied ${scssFile} to ${outputFile}`); | ||
fs.copyFileSync(scssFile, outputFile) | ||
console.log(`Successfully copied ${scssFile} to ${outputFile}`) | ||
} catch (error) { | ||
console.error('Error including display SCSS file:', error); | ||
console.error('Error including display SCSS file:', error) | ||
} | ||
}, | ||
undo: (dictionary, config) => { | ||
try { | ||
const outputDir = path.join(__dirname, '../../', config.buildPath); | ||
const outputDir = path.join(__dirname, '../../', config.buildPath) | ||
|
||
// Remove the output directory and its contents | ||
fs.removeSync(outputDir); | ||
console.log(`Successfully removed ${outputDir}`); | ||
fs.removeSync(outputDir) | ||
console.log(`Successfully removed ${outputDir}`) | ||
} catch (error) { | ||
console.error('Error removing display SCSS file directory:', error); | ||
console.error('Error removing display SCSS file directory:', error) | ||
} | ||
} | ||
}); | ||
}; | ||
}) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,38 +1,38 @@ | ||
import fs from 'fs-extra'; | ||
import path from 'path'; | ||
import { getDirname } from '../utils.mjs'; | ||
import fs from 'fs-extra' | ||
import path from 'path' | ||
import { getDirname } from '../utils.mjs' | ||
|
||
const __dirname = getDirname(import.meta.url); | ||
const __dirname = getDirname(import.meta.url) | ||
|
||
export const includeMediaQueriesLess = (StyleDictionary) => { | ||
StyleDictionary.registerAction({ | ||
name: 'include-media-queries-less', | ||
do: (dictionary, config) => { | ||
try { | ||
const lessFile = path.join(__dirname, '../utilities/media-queries.less'); | ||
const outputDir = path.join(__dirname, '../../', config.buildPath); | ||
const outputFile = path.join(outputDir, 'media-queries.less'); | ||
const lessFile = path.join(__dirname, '../utilities/media-queries.less') | ||
const outputDir = path.join(__dirname, '../../', config.buildPath) | ||
const outputFile = path.join(outputDir, 'media-queries.less') | ||
|
||
// Ensure the output directory exists | ||
fs.ensureDirSync(outputDir); | ||
fs.ensureDirSync(outputDir) | ||
|
||
// Copy the LESS file to the output directory | ||
fs.copyFileSync(lessFile, outputFile); | ||
console.log(`Successfully copied ${lessFile} to ${outputFile}`); | ||
fs.copyFileSync(lessFile, outputFile) | ||
console.log(`Successfully copied ${lessFile} to ${outputFile}`) | ||
} catch (error) { | ||
console.error('Error including media queries LESS file:', error); | ||
console.error('Error including media queries LESS file:', error) | ||
} | ||
}, | ||
undo: (dictionary, config) => { | ||
try { | ||
const outputDir = path.join(__dirname, '../../', config.buildPath); | ||
const outputDir = path.join(__dirname, '../../', config.buildPath) | ||
|
||
// Remove the output directory and its contents | ||
fs.removeSync(outputDir); | ||
console.log(`Successfully removed ${outputDir}`); | ||
fs.removeSync(outputDir) | ||
console.log(`Successfully removed ${outputDir}`) | ||
} catch (error) { | ||
console.error('Error removing media queries LESS file directory:', error); | ||
console.error('Error removing media queries LESS file directory:', error) | ||
} | ||
} | ||
}); | ||
}; | ||
}) | ||
} |
Oops, something went wrong.