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

Initializer for react-native sample #879

Merged
merged 108 commits into from
Dec 15, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
108 commits
Select commit Hold shift + click to select a range
08a1235
WIP: nextjs generator
Nov 15, 2021
0c22440
WIP: diy generator
Nov 16, 2021
1b063a6
WIP: nextjs generator - build templates
Nov 16, 2021
af1526c
Start of dedicated package 'create-sitecore-jss'
ambrauer Nov 16, 2021
95a9b8c
remove package-lock
ambrauer Nov 16, 2021
06143ae
Stubbed out build-templates.ts, added .gitignore
ambrauer Nov 16, 2021
9db0d7e
added build templates
addy-pathania Nov 17, 2021
d333ed8
WIP: nextjs initializer- ejs file render
Nov 17, 2021
f606310
Handling template command line parameter / prompt
ambrauer Nov 17, 2021
e046d58
Allow token replacement on file names
ambrauer Nov 17, 2021
d13a632
remove remaining disconnected files
ambrauer Nov 17, 2021
58a4e6e
Added check for empty directory
ambrauer Nov 17, 2021
d370675
Remove remaining styleguide code
ambrauer Nov 17, 2021
175bed0
test name change for lerna versioning
ambrauer Nov 17, 2021
0847304
updated yarn.lock
ambrauer Nov 17, 2021
451c35d
lerna test
ambrauer Nov 17, 2021
1036285
Revert "lerna test"
ambrauer Nov 17, 2021
3d18acf
get rid of mkdirp helper in favor of fs-extra
ambrauer Nov 17, 2021
4765263
Add support for 'add' positinal param
Nov 18, 2021
010a3b3
Initial watch script
ambrauer Nov 18, 2021
6ffd8cd
Fix templates, add prefix flag
Nov 18, 2021
ac78d03
added logs, detect initializer, feed args from json
addy-pathania Nov 19, 2021
c044535
refined the config file and added switch case to initializers
addy-pathania Nov 19, 2021
53b1dc1
merged with diy-generator-watch
addy-pathania Nov 19, 2021
9320377
Adding diffing to 'add'
Nov 19, 2021
066b79f
Fix merge conflict
Nov 19, 2021
ce6228d
Styleguide sub-initializer WIP: prompts for diffs working
Nov 22, 2021
d62357a
Update yes flag to override with passed in args
Nov 22, 2021
2a3eeef
WIP: Add dependencies/scripts to package.json during post-init
Nov 22, 2021
f592b84
Basic "next steps" introduced, some linting errors fixed
ambrauer Nov 22, 2021
029724e
WIP: Removing code duplication between files, start refactor package.…
Nov 22, 2021
d688043
Fix merge conflicts
Nov 22, 2021
082ceb3
WIP: package.json, lint
Nov 23, 2021
007a376
Add diff prompt to package.json, use diffJson method for .json files
Nov 23, 2021
64d0919
Add jss cli to base nextjs template and remove message about yarn
Nov 23, 2021
6be06ac
Add diff to package.json, add some missing template files
Nov 23, 2021
128a9d2
Move styleguide Navigation component to proper place in src, fix tsco…
Nov 23, 2021
d7972de
Remove unused stuff in cli package
Nov 24, 2021
804ea27
Diy generator yarn install (#861)
CobyPear Nov 24, 2021
b52ba85
Merge branch 'diy-generator' of github.com:Sitecore/jss into diy-gene…
Nov 24, 2021
a6a9696
Update error handling for transformFiles
Nov 24, 2021
d63f457
Start adding unit tests for shared functions
Nov 24, 2021
191cf82
Add test(s)
Nov 24, 2021
7b17dd1
Add error message when adding post-init to non-JSS app
Nov 29, 2021
709c748
Reorganize and refactor some base functionality
Nov 29, 2021
f3069e6
WIP: Unit tests for helpers
Nov 29, 2021
4e4992c
Add coverage script, add support for deep merge of package.json files
illiakovalenko Nov 30, 2021
c5271bc
Cover helpers by UT
illiakovalenko Nov 30, 2021
f47f486
Cover diffFiles by UT
illiakovalenko Nov 30, 2021
81c4bd2
Minor fixes
Nov 30, 2021
292ce78
Fix isJssApp UT
Nov 30, 2021
4497111
merged with dev
addy-pathania Nov 30, 2021
b7a544e
merge with dev and refactor
addy-pathania Nov 30, 2021
94e62f6
Update diffFiles test, fix sinon wrap error
Nov 30, 2021
6c93952
Add litFix command, add missing ejs logic to connected demo tsx
Nov 30, 2021
0a028d5
group tests
illiakovalenko Dec 1, 2021
205e898
Cover transform by UT
illiakovalenko Dec 1, 2021
db02682
Cover cmd by UT
illiakovalenko Dec 1, 2021
9e0e23d
Restructure folders, delay install
Dec 1, 2021
a9e474b
Fixes before demo
Dec 2, 2021
cffc43d
Merge branch 'dev' into diy-generator
ambrauer Dec 3, 2021
0ad2efe
NextjsAnswer cleanup (remove redundant props, move/rename file to fol…
ambrauer Dec 3, 2021
9642ce6
apply sitemap-fetcher plugin for disconnected
ambrauer Dec 3, 2021
06131ff
apply next.config plugin changes
ambrauer Dec 3, 2021
18813cd
Remove unnecessary devDependencies (main packages include own type de…
ambrauer Dec 3, 2021
9bd1354
Rename transformPostInit to writeFiles, fix some tests
Dec 3, 2021
f98485e
remove monorepo dev dependencies if dev environment
ambrauer Dec 3, 2021
3c746f3
Merge branch 'diy-generator' of https://github.com/Sitecore/jss into …
ambrauer Dec 3, 2021
dc1d1d4
Fix scaffold script
Dec 3, 2021
a25edd4
added tests for writePackageJson helper
ambrauer Dec 3, 2021
000cf2d
Revert "Fix scaffold script"
Dec 3, 2021
7adb382
Merge branch 'diy-generator' of github.com:Sitecore/jss into diy-gene…
Dec 3, 2021
636993b
scaffold-component updates for disconnected/styleguide
ambrauer Dec 6, 2021
907ad28
removed extra sitemapFetcher import
ambrauer Dec 6, 2021
f7f60b7
fix removeDevDependencies check, consolidation in [[...path]].tsx
ambrauer Dec 6, 2021
9a9f5f2
added _app.tsx (with bootstrap, nprogress) for nextjs-styleguide
ambrauer Dec 6, 2021
77720aa
"yes" handling for subsequent initializers (don't prompt for diffs wh…
ambrauer Dec 6, 2021
073f05d
only pass along __true__ "yes" answers
ambrauer Dec 6, 2021
677833d
Initializers internationalization (#868)
illiakovalenko Dec 7, 2021
4306bdb
[NextJS] Refactor scaffold script to make it pluggable (#870)
illiakovalenko Dec 8, 2021
36fb787
[Initializers] Refactor prompts and answers (#872)
illiakovalenko Dec 8, 2021
c3aa4b2
Update some ejs closing tags to trim unwanted newline
Dec 8, 2021
39dad38
Refactor post-initializer flow (#874)
ambrauer Dec 8, 2021
e2abce1
Add react-native templates
Dec 8, 2021
dc8846a
Add ejs templating for appName and config
Dec 8, 2021
0537543
More template prep
Dec 8, 2021
81aa5f8
Fixed watch mode
ambrauer Dec 8, 2021
8d2e075
* #511292 fixed issue where transform wasn't occurring on package.jso…
ambrauer Dec 8, 2021
06a0c81
only run lint --fix if a lint script exists
ambrauer Dec 8, 2021
ec83bad
Add react-native initializer
Dec 9, 2021
cfdfb5e
Merge branch 'diy-generator' of github.com:Sitecore/jss into diy-gene…
Dec 9, 2021
4c1480d
[Initializers] Split `force`, `yes` flags (#877)
illiakovalenko Dec 9, 2021
a779bbf
Merge branch 'diy-generator' of github.com:Sitecore/jss into diy-gene…
Dec 9, 2021
63288cb
Add dynamic logic to init factory and base templates prompt choices
Dec 9, 2021
4b270d9
Add silent option to run
Dec 9, 2021
267dc26
Merge branch 'diy-generator' of github.com:Sitecore/jss into diy-gene…
Dec 9, 2021
7be735b
Update initializer and fix a template
Dec 9, 2021
89c8e53
Apply changes from comments
Dec 10, 2021
0330ada
Merge branch 'dev' of github.com:Sitecore/jss into diy-generator-reac…
Dec 14, 2021
1ab5249
Update interfaces for ReactNative
Dec 14, 2021
8063ecb
Remove typo
Dec 14, 2021
1e48e46
Remove settings.json extra
Dec 14, 2021
2fc6e03
Fixes
Dec 14, 2021
75711ec
Remove yes from react-native init response
Dec 14, 2021
03a9d58
Move ReactNativeArgs
Dec 14, 2021
ad70591
Update import
Dec 14, 2021
b89cca8
Change asset regex name and to include .jar file
Dec 14, 2021
415549c
Update node and npm versions in package.json template
Dec 15, 2021
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
4 changes: 2 additions & 2 deletions packages/create-sitecore-jss/src/common/steps/transform.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ import {
import { diffLines, diffJson, Change } from 'diff';
import { BaseArgs } from '../args/base';

const ASSET_REGEX = /\.(gif|jpg|jpeg|tiff|png|svg|ashx|ico|pdf)$/;
const COPY_ONLY_REGEX = /\.(gif|jpg|jpeg|tiff|png|svg|ashx|ico|pdf|jar)$/;

export type JsonPropertyType = number | string | (number | string)[] | JsonObjectType;
export interface JsonObjectType {
Expand Down Expand Up @@ -186,7 +186,7 @@ export const transform = async (
// if the directory doesn't exist, create it
fs.mkdirsSync(path.dirname(transformFilename(pathToNewFile, answers)));

if (file.match(ASSET_REGEX)) {
if (file.match(COPY_ONLY_REGEX)) {
// pdfs may have <% encoded, which throws an error for ejs.
// we simply want to copy file if it's a pdf, not render it with ejs.
fs.copySync(pathToTemplate, pathToNewFile);
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
import { BaseArgs } from '../../common/args/base';
import { ClientAppAnswer } from '../../common/prompts/base';

export interface ReactNativeArgs extends BaseArgs, Partial<Omit<ClientAppAnswer, 'fetchWith'>> {}
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
import path from 'path';
import { prompt } from 'inquirer';
import { prompts, ReactNativeAnswer } from './prompts';
import { Initializer } from '../../common/Initializer';
import { transform } from '../../common/steps';
import { ReactNativeArgs } from './args';

export default class ReactNativeInitializer implements Initializer {
get isBase() {
return true;
}

async init(args: ReactNativeArgs) {
const defaults = args.yes
? {
appName: 'sitecore-jss-react-native',
hostName: 'https://cm.jss.localhost',
language: '',
}
: {};

const answers = await prompt<ReactNativeAnswer>(prompts, { ...defaults, ...args });

const mergedArgs = {
...args,
...answers,
};

const templatePath = path.resolve(__dirname, '../../templates/react-native');
await transform(templatePath, mergedArgs, {
filter: (filePath: string) =>
!!mergedArgs.language || !filePath.endsWith('{{language}}.json'),
});

const response = {
appName: answers.appName,
};

return response;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
import { DistinctQuestion, QuestionCollection } from 'inquirer';
import { styleguidePrompts, StyleguideAnswer } from '../../common/prompts/styleguide';
import { clientAppPrompts, ClientAppAnswer } from '../../common/prompts/base';

export interface ReactNativeAnswer extends Omit<ClientAppAnswer, 'fetchWith'>, StyleguideAnswer {}

export const prompts: QuestionCollection<ReactNativeAnswer> = [
...clientAppPrompts.filter((p: DistinctQuestion) => p.name !== 'fetchWith'),
...styleguidePrompts,
];
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@

[android]
target = Google Inc.:Google APIs:23

[maven_repositories]
central = https://repo1.maven.org/maven2
74 changes: 74 additions & 0 deletions packages/create-sitecore-jss/src/templates/react-native/.eslintrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
{
"root": true,
"parser": "babel-eslint",
"parserOptions": {
"ecmaFeatures": {
"jsx": true
}
},
"extends": [
"airbnb-base",
"plugin:react/recommended",
"prettier",
"prettier/react",
"plugin:import/errors",
"plugin:import/warnings"
],
"plugins": ["react", "react-native", "import", "prettier"],
"settings": {
"import/ignore": ["node_modules", ".png$", ".jpg$"],
"import/resolver": {
"babel-module": {}
},
"react": {
"version": "detect"
}
},
"env": {
"jest": true
},
"rules": {
"jsx-quotes": ["error", "prefer-double"],
"react/prop-types": "off",
"prettier/prettier": "error",
"import/prefer-default-export": "off",
"import/no-extraneous-dependencies": [
"error",
{
"devDependencies": true,
"optionalDependencies": true
}
],
"linebreak-style": ["error", "windows"],
"arrow-body-style": ["warn", "as-needed"],
"arrow-parens": ["error", "always"],
"no-unused-vars": [
"error",
{
"args": "none"
}
],
"func-names": "off",
"no-console": "off",
"radix": ["error", "as-needed"],
"prefer-destructuring": "off",
"no-useless-escape": "off",
"spaced-comment": "error",
"curly": ["error", "multi-line"],
"eol-last": ["error", "always"],
"guard-for-in": "error",
"no-unused-labels": "error",
"no-caller": "error",
"no-bitwise": "error",
"no-multiple-empty-lines": "error",
"no-new-wrappers": "error",
"no-eval": "error",
"dot-notation": "error",
"no-trailing-spaces": "error",
"no-unused-expressions": ["error", { "allowShortCircuit": true, "allowTernary": true }],
"brace-style": "error",
"quotes": ["error", "single"],
"default-case": "error",
"eqeqeq": "error"
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
*.pbxproj -text
60 changes: 60 additions & 0 deletions packages/create-sitecore-jss/src/templates/react-native/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
# OSX
#
.DS_Store

# Xcode
#
ios/**/build/
*.pbxuser
!default.pbxuser
*.mode1v3
!default.mode1v3
*.mode2v3
!default.mode2v3
*.perspectivev3
!default.perspectivev3
xcuserdata
*.xccheckout
*.moved-aside
DerivedData
*.hmap
*.ipa
*.xcuserstate
project.xcworkspace

# Android/IntelliJ
#
android/**/build/
.idea
.gradle
local.properties
*.iml

# node.js
#
node_modules/
*.log

# BUCK
buck-out/
\.buckd/
*.keystore
!debug.keystore

# fastlane
#
# It is recommended to not store the screenshots in the git repo. Instead, use fastlane to re-generate the
# screenshots whenever they are needed.
# For more information about the recommended setup visit:
# https://docs.fastlane.tools/best-practices/source-control/

*/fastlane/report.xml
*/fastlane/Preview.html
*/fastlane/screenshots

# CocoaPods
/ios/Pods/

# sitecore

*.deploysecret.config
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
{
"endOfLine": "crlf",
"singleQuote": true,
"trailingComma": "es5",
"tabWidth": 2,
"arrowParens": "always",
"printWidth": 100
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
{
// Use IntelliSense to learn about possible attributes.
// Hover to view descriptions of existing attributes.
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
"version": "0.2.0",
"configurations": [
{
"name": "Debug Android",
"program": "${workspaceRoot}/.vscode/launchReactNative.js",
"type": "reactnative",
"request": "launch",
"platform": "android",
"sourceMaps": true,
"outDir": "${workspaceRoot}/.vscode/.react"
},
{
"name": "Debug iOS",
"program": "${workspaceRoot}/.vscode/launchReactNative.js",
"type": "reactnative",
"request": "launch",
"platform": "ios",
"sourceMaps": true,
"outDir": "${workspaceRoot}/.vscode/.react"
},
{
"name": "Attach to packager",
"program": "${workspaceRoot}/.vscode/launchReactNative.js",
"type": "reactnative",
"request": "attach",
"sourceMaps": true,
"outDir": "${workspaceRoot}/.vscode/.react"
},
{
"name": "Debug in Exponent",
"program": "${workspaceRoot}/.vscode/launchReactNative.js",
"type": "reactnative",
"request": "launch",
"platform": "exponent",
"sourceMaps": true,
"outDir": "${workspaceRoot}/.vscode/.react"
}
]
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
{
}
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{}
Loading