Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: migrate generator package to root #2245

Merged
merged 1 commit into from
Oct 31, 2023
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
2 changes: 1 addition & 1 deletion .prettierignore
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ components/vars/css/**/*.css
components/vars/custom.css
components/tokens/custom-*/*.css
tools/preview/storybook-static/**
tools/generator
generator
dist
template.hbs

Expand Down
File renamed without changes.
2 changes: 1 addition & 1 deletion tools/generator/package.json → generator/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
"repository": {
"type": "git",
"url": "https://github.com/adobe/spectrum-css.git",
"directory": "tools/generator"
"directory": "generator"
},
"bugs": {
"url": "https://github.com/adobe/spectrum-css/issues"
Expand Down
8 changes: 4 additions & 4 deletions tools/generator/plopfile.js → generator/plopfile.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,11 @@ import { existsSync, readdirSync, readFileSync } from 'fs';
import { readFile } from 'fs/promises';
import { resolve } from 'path';

import yaml from 'js-yaml';
import cheerio from 'cheerio';
import yaml from 'js-yaml';

import autocompletePrompt from 'inquirer-autocomplete-prompt';
import fuzzy from 'fuzzy';
import autocompletePrompt from 'inquirer-autocomplete-prompt';

const fetchPackage = async (path) =>
readFile(resolve(path, 'package.json'), {
Expand All @@ -17,13 +17,13 @@ const fetchPackage = async (path) =>

export default async (plop) => {
/* Allow customization from the environment variables */
const rootFolder = process.env.ROOT_DIR ?? resolve(process.cwd(), '../../');
const rootFolder = process.env.ROOT_DIR ?? resolve(process.cwd(), '../');
const srcPath = process.env.COMPONENT_DIR ?? resolve(rootFolder, 'components');
const projectName = process.env.PROJECT_NAME ?? 'Spectrum CSS';
const pkg = await fetchPackage(rootFolder);

const tokens = await fetchPackage(resolve(srcPath, 'tokens'));
const builder = await fetchPackage(resolve(process.cwd(), '../component-builder-simple'));
const builder = await fetchPackage(resolve(process.cwd(), '../tools/component-builder-simple'));

/* Fetch the project name */
plop.setWelcomeMessage(`Welcome to the ${projectName} component generator!\n To get started, answer a few short questions about your component.`);
Expand Down
6 changes: 4 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -41,10 +41,11 @@
"postdocs:mod": "prettier --cache --write components/*/metadata/*.md > /dev/null",
"lint:components": "node ./tasks/packageLint.js",
"lint:styles": "stylelint",
"migration:clean": "test -n \"${BASH_VERSION}\" && bash ./tasks/clean-up-after-migration.sh || exit 0",
"mv:preview": "rimraf dist/preview && mv tools/preview/storybook-static dist/preview",
"new": "nx run @spectrum-css/generator:new",
"precommit": "lint-staged",
"prepare": "husky install",
"prepare": "husky install && yarn migration:clean",
"prepare:site": "run-s clean:docs build:all",
"prerelease": "yarn version:build",
"release": "lerna publish",
Expand All @@ -61,7 +62,8 @@
"workspaces": [
"components/*",
"tools/*",
"plugins/*"
"plugins/*",
"generator"
],
"devDependencies": {
"@adobe/focus-ring-polyfill": "^0.1.5",
Expand Down
34 changes: 34 additions & 0 deletions tasks/clean-up-after-migration.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
#!/usr/bin/bash

# Copyright 2023 Adobe. All rights reserved.
# This file is licensed to you under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License. You may obtain a copy
# of the License at http://www.apache.org/licenses/LICENSE-2.0

# Unless required by applicable law or agreed to in writing, software distributed under
# the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
# OF ANY KIND, either express or implied. See the License for the specific language
# governing permissions and limitations under the License.

# After migrating from our old build system, there are a lot of empty folders hanging out still
# This script aims to clean up those folders

# Legacy tools folder (included storybook & generator)
# test -d "tools" && rm -rf tools

test -d "tools/generator" && rm -rf tools/generator

# Legacy tokens packages
# test -d "components/vars" && rm -rf components/vars
# test -d "components/expressvars" && rm -rf components/expressvars
# test -d "components/tokens" && rm -rf components/tokens

# test -d "plugins/legacy-postcss-dropdupedvars" && rm -rf plugins/legacy-postcss-dropdupedvars
# test -d "plugins/legacy-postcss-dropunusedvars" && rm -rf plugins/legacy-postcss-dropunusedvars
# test -d "plugins/postcss-combininator" && rm -rf plugins/postcss-combininator
# test -d "plugins/postcss-dropdupedvars" && rm -rf plugins/postcss-dropdupedvars
# test -d "plugins/postcss-droproot" && rm -rf plugins/postcss-droproot
# test -d "plugins/postcss-dropunusedvars" && rm -rf plugins/postcss-dropunusedvars
# test -d "plugins/postcss-remapvars" && rm -rf plugins/postcss-remapvars
# test -d "plugins/postcss-transformselectors" && rm -rf plugins/postcss-transformselectors
# test -d "plugins/postcss-varfallback" && rm -rf plugins/postcss-varfallback